[Meta][2.14] Support Multiple Data Source in OpenSearch Dashboards Plugins #5870
Labels
dashboards anywhere
label for dashboards anywhere
multiple datasource
multiple datasource project
v2.14.0
Context
Since 2.4.0, multiple data source feature is enabled as a core plugin(see RFC #1388 and PR #2334).
With multiple data source enabled, users of OpenSearch Dashboards are able to create data source connections and query local and remote OpenSearch clusters(see documentation https://opensearch.org/docs/latest/dashboards/management/data-sources/). Enabling multiple data source at dashboards plugin would ensure users that have been using the multiple data source feature to have a consistent experience in the dashboard, and allows users to use the same dashboard for different clusters.
This meta issue is used to track the PR/Issues for supporting multiple data source in OpenSearch Dashboards Plugins
Data source connection picker
In #5717, we introduced a picker to select data connection. This picker is within the data source plugin bundle, and when loaded, it will fetch data source connection which is a type of saved object and then populate the available data connections as single selected options in the drop down.
In order to consume this picker from a plugin, follow the steps as below:
Data source client
Data source plugin was released in OpenSearch Dashboards 2.4.0 as part of the multi data source feature.
The plugin exposes OpenSearch client wrapper and this is the design https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/docs/multi-datasource/client_management_design.md, it can be acquired from context via the following:
client: OpenSearchClient = await context.dataSource.opensearch.getClient(dataSourceId);
For legacy client, we can initiate the client via the following
apiCaller: LegacyAPICaller = context.dataSource.opensearch.legacy.getClient(dataSourceId).callAPI;
Note that we need to pass in the data source id as argument, and this id can be acquired by passing a function to the child component by following instructions above.
PoC
PoC commit for query bench dashboards plugin to support MDS: opensearch-project/dashboards-query-workbench@main...BionIT:dashboards-query-workbench:mdinteg
A few things to notice:
"optionalPlugins": ["dataSource"]
in opensearch_dashboards.json in the plugin repo"requiredBundles": ["dataSourceManagement"]
dataSource.registerCustomApiSchema(sqlPlugin)
const {dataSourceId} = request.query;
then the datasource Id can be passed to the data source client wrappercontext.dataSource.opensearch.getClient(dataSourceId)
The text was updated successfully, but these errors were encountered: