Closed mengweieric closed 6 months ago
I like the overall goal here to have a unified datasource selector that can be used across apps, however i would keep application specific details out of such a data selector since it limits where it can be used and how. For example, I like the Datasource registration and dataset retrieval part of the design, and even like how we can expose a common datasource selector UI component. The thing i'd keep out of this though is the context and language switching features since those are usually application specific. Let the underlying application handle that. Based on the datasource selected, the underlying application may choose to do different things based on the users context, something that the datasource service may not be aware of.
Overview
Flint and several other projects are broadening OpenSearch's capabilities, enabling it to not only support consuming OpenSearch's internal data but also data from external data sources like S3, CloudWatch and Prometheus. Once these external data sources are appropriately configured, they will be made available for selection from both data explorer and other plugins including Dashboards Observability. This document aims to discuss the datasource selector as a new user interface for shared datasource selection experience in OpenSearch Dashboards.
Requirements
Functional
Non-functional
UX Design
Prototype Overview - Datasource selector
When utilized within the data explorer, this feature will be positioned in the top left corner of the left-hand panel with title ‘Data source’.
Data Explorer with Datasource selector (Observability view)
Workflow Overview
The datasource selector and the services behind it are responsible for several tasks when managing datasource selection
Architecture Proposal
To meet the outlined requirements, we will introduce a new datasource service in Dashboard core. this, when in place, is extending the current data source plugin's capabilities, enabling it to be able to support integrating not only OpenSearch datasources but also other datasources. Each integrated datasource will operate as an independent instance encompassing its own unique set of services, settings, components etc, and made available across OpenSearch Dashboards.
Components
OUI Integration
As part of our ongoing efforts to improve and standardize the user interface of OpenSearch, and the increasing use cases for the need of having a datasource selector, we propose the new datasource selector UI (pure react component mentioned above) to eventually be a OUI component. The component will initially be developed using OUI Combo Box in the P0 phase, and then be evolved into an OUI component in the OUI framework.
Location of Datasource Codebase
The entire datasource selection system will comprise a set of frontend functionalities sitting within the public folder of the core data_source plugin. These functionalities will be made accessible via the setup hook in plugin.ts. Any core components or plugins that list data_source as a dependency will have access to this datasource service. During the plugin setup stage, the datasource service initiates, reading all available data sources metadata. These metadata is then used to initialize the datasources for selecting in selector and their corresponding components and APIs.
Interfaces and Classes
Datasource
Every instance of the datasource is fundamentally an abstraction of a specific datasource connection. Depending on its type, a datasource may have one or several instances. Given that the design of the datasource selector UI also displays the dataset (for example, index patterns as dataset for an OpenSearch datasource, tables as dataset for a flint datasource) associated with a datasource connection, each datasource implementation of getDataSet must account for their unique method of fetching the respective dataset.
Datasource Service
Datasource Pluggable
Each datasource type is accompanied by one pluggable module. This module contains a collection of UI components, along with any other custom components required to render when the corresponding datasource is selected.
Each datasource type is associated with a unique pluggable module. For instance, if we have three types of datasources - a default local cluster, an external OpenSearch cluster, and a Flint datasource, when the data_source plugin is loaded, it will expose three distinct pluggable modules, each corresponding to one of these datasource types. Data explorer or any other frame or platform uses the datasource type to access the plugin modules.
Datasource Integration
Onboarding Datasource
Every datasource connection in OpenSearch Dashboards, whether initialized at startup (as with default datasources) or during runtime (when creating a new connection), need to go through the following 1st and 3rd steps to be integrated into the datasource selector.
1. Datasource creation
Owners of datasources are responsible for constructing their datasource classes. They should base their decision on the level of shared functionalities with existing classes in the inheritance chain of the datasource.
2. Datasource plugin creation (optional, out of scope in p0 for core, Observability only)
In phase 0, the datasource pluggable will reside within the Observability plugin temporarily. Subsequent decisions will determine whether it should be promoted to the core datasource plugin functionalities.
Owners of datasources are also responsible for constructing their datasource plugin classes for new datasource type or adding their custom components to the existing datasource type pluggable if they have custom components to render. Since we have view registration in data explorer, in p0, creating pluggable for OpenSearch datasource type is not required for core, but observability will rely on this pluggable for dynamically render UI components internally.
3. Datasource registration:
Owners of datasources are also responsible for registering their datasource with core datasource service, by calling registerDatasource API that datasource service exposes.
Using selector UI independently
Consumers who only require the datasource selection UI, and not the entire service, have the option to use just that part. Datasource selector component is essentially a wrapper around the OUI combo box. Therefore, instead of implementing the full datasource, they can integrate only the datasource selector UI into their applications.