Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature][MDS] TSVB support with Multi data source #6005

Closed
Tracked by #5872
bandinib-amzn opened this issue Mar 3, 2024 · 1 comment · Fixed by #6298
Closed
Tracked by #5872

[Feature][MDS] TSVB support with Multi data source #6005

bandinib-amzn opened this issue Mar 3, 2024 · 1 comment · Fixed by #6298
Assignees
Labels
enhancement New feature or request multiple datasource multiple datasource project v2.14.0

Comments

@bandinib-amzn
Copy link
Member

Problem Statement

As of today, the Time Series Visual Builder (TSVB) - a data visualization tool in Dashboards - does not support remote data connections. However, Dashboards can connect to any remotely located OpenSearch instance through connections created using the data source feature.

Background

Currently TSVB is tightly integrated with OpenSearch. TSVB directly queries OpenSearch to retrieve the time-series data needed for visualization. TSVB relies on index patterns defined in OpenSearch-Dashboards to identify the OpenSearch indices containing the relevant data.

There are two APIs /api/metrics/fields and /api/metrics/vis/data which are part of the Time Series Visual Builder (TSVB) plugin in OpenSearch-Dashboards. They are used for fetching field metadata and metric data for visualizations, respectively.

  1. /api/metrics/fields: This API endpoint is responsible for providing information about the fields available in the indices that TSVB can query. It returns metadata such as the data type, format, and other properties of the fields. This information is crucial for configuring TSVB visualizations as it helps users understand the structure of the data they are working with.

  2. /api/metrics/vis/data: This API endpoint is used to retrieve metric data for TSVB visualizations. It allows users to specify parameters such as the time range, interval, and other options to fetch the relevant metric data from OpenSearch. The data retrieved from this endpoint is then used to render the TSVB visualization in the OpenSearch-Dashboards.

These APIs are essential for the functionality of TSVB as they enable users to interact with OpenSearch and fetch the data needed for creating and displaying time-series visualizations in Dashboards. To enable TSVB to connect and retrieve data from a remote cluster, we need to add support for data sources within these two APIs.

Solution

1] Modify Index Pattern selector under Panel Options and Annotation:

The current input type of the Index pattern selector in TSVB is a text field. We need to extend the functionality of this text fields to support index pattern of format [Data Source]::[Index Pattern].

2] Modify /api/metrics/fields to accept dataSourceId as query parameter:

2.1 Add data source id as query parameter

export const fieldsRoutes = (framework: Framework) => {
framework.router.get(
{
path: '/api/metrics/fields',
validate: {
query: schema.object({ index: schema.string() }),
},
},

2.2 And then pass to getFields

return res.ok({ body: await getFields(context, req, framework, req.query.index) });

2.3 Then inside getFields, based on dataSourceId, we need to IndexPatternsFetcher with correct client.

pre: {
indexPatternsService: new IndexPatternsFetcher(
requestContext.core.opensearch.legacy.client.callAsCurrentUser
),

3] Modify /api/metrics/vis/data to accept dataSourceId as query parameter:

/api/metrics/vis/data uses data plugin for search and query OpenSearch. Data plugin already have capability to accept dataSourceID and decide client based on context and request.

3.1 Add data source id as query parameter

router.post(
{
path: '/api/metrics/vis/data',
validate: {
body: escapeHatch,
},
},

3.2 Then pass dataSourceId to search.

deps.data.search.search(
req.requestContext,
{
params: {
...body,
...this.additionalParams,
},
indexType: this.indexType,
},

Alternate Solution

For 1st point in proposed solution, instead of extending the functionality of this text fields to support index pattern of format [Data Source]::[Index Pattern], use same component which is being used in Discover.

Screenshot 2024-03-03 at 2 43 25 AM
@seraphjiang
Copy link
Member

#2153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request multiple datasource multiple datasource project v2.14.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants