OpenSearch-Dashboards icon indicating copy to clipboard operation
OpenSearch-Dashboards copied to clipboard

[Feature][MDS] Add data source support to Timeline visualization

Open bandinib-amzn opened this issue 11 months ago • 0 comments

Problem Statement

As of today, timeline visualization does not support remote data connections, which can be established using the data source feature

Background

OpenSearch Dashboards Timeline is a visualization tool used to create time-series charts and analyze time-series data in OpenSearch. Timeline uses a unique syntax to create time-series visualizations. The syntax includes a chain of commands that are executed in a particular order. More information can be found here

The .opensearch() function in Timeline is one of the most fundamental functions used to query data from OpenSearch indices. It is primarily used to retrieve time series data for visualization. As other functions, .opensearch() function also have multiple parameters. Considering scope of this issue(feature), we will only discuss about index parameter.

Params index: Specify the OpenSearch index to retrieve data from.

example:

.opensearch(index=opensearch_dashboards_sample_data_logs)

Proposed Solution: 1] Add an additional parameter to the .opensearch() function to specify the data source from which to retrieve the index.

.opensearch(index=opensearch_dashboards_sample_data_logs,datasource: some_datasource_id)

2] Modify /api/timeline/run API

The Timeline expression language allows users to define complex time series calculations and visualizations. The /api/timeline/run endpoint could be used to generate these expressions dynamically based on user input or other parameters. Once a Timeline expression is defined, it needs to be executed to retrieve the time series data and generate the visualization. The /api/timeline/run endpoint likely handles the execution of these expressions and returns the results in a format that can be consumed by client applications.

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

We need to implement the logic to retrieve data source id from function parameter and pass that data source id while building request before calling search API.

https://github.com/opensearch-project/OpenSearch-Dashboards/blob/c6b4c34956d51c9fc60210ae9b0b3477d58eee5f/src/plugins/vis_type_timeline/server/series_functions/opensearch/lib/build_request.js#L107-L109

so the above code would become

export default function buildRequest(config, tlConfig, scriptedFields, timeout) {
.
.
.
return {
    params: request,
    dataSourceId: 'some_datasource_id',
  };
}

bandinib-amzn avatar Mar 04 '24 02:03 bandinib-amzn