[MDS] Support for Timeline#6385
Conversation
|
Before rebase: |
| import { getDataSourceEnabled } from './services'; | ||
| import { OpenSearchFunctionConfig } from '../types'; | ||
|
|
||
| export const fetchDataSourceIdByName = async ( |
There was a problem hiding this comment.
Didn't we define similar function for vega? In vega, we are fetching data source id by name, right? Correct me if I'm missing something.
There was a problem hiding this comment.
Yes but Vega fetches data source id client-side while Timeline fetches data source id information server-side. I agree that this is something that needs to be refactored into one utility function in data source plugin and I cut a new issue #6417
There was a problem hiding this comment.
Is there an ETA to refactor this function? Just asking because if we don't actively track and then we will keep using these two separate function when they are performing same functionality.
There was a problem hiding this comment.
I'm not sure if this is a huge priority at the moment. Most plugins are not blocked by this refactor, but once the UI components are finalized (these are blocking issues), I will pick up this task. This should be started within this sprint or at the most, next sprint.
| throw new Error( | ||
| `Expected exactly 1 result for data_source_name "${config.data_source_name}" but got ${possibleDataSourceIds.length} results` |
There was a problem hiding this comment.
Is this user facing error?
There was a problem hiding this comment.
Yes. Timeline parses the expression server-side and throws an Error if the expression is incorrectly written. This will behave the same way.
| /** | ||
| * @deprecated The interval picker should be used instead | ||
| */ | ||
| interval: string | null; |
There was a problem hiding this comment.
what is meaning of comment? It is deprecated and we are still using it?
There was a problem hiding this comment.
In the Timeline expression, there is an option for the user to specify an interval. However, as noted in the opensearch function args, there is a picker react component that users should use instead. I assume interval is kept as to not break any existing visualization so I marked it as deprecated.
| /** | ||
| * @deprecated The interval picker should be used instead | ||
| */ | ||
| interval: string | null; |
| import { getDataSourceEnabled } from './services'; | ||
| import { OpenSearchFunctionConfig } from '../types'; | ||
|
|
||
| export const fetchDataSourceIdByName = async ( |
There was a problem hiding this comment.
Is there an ETA to refactor this function? Just asking because if we don't actively track and then we will keep using these two separate function when they are performing same functionality.
| ) => { | ||
| if (config.data_source_name) { | ||
| if (!getDataSourceEnabled().enabled) { | ||
| throw new Error('To query from multiple data sources, first enable the data sources feature'); |
There was a problem hiding this comment.
nit: shouldn't be enable the data source feature?
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
| await expect( | ||
| fetchDataSourceIdByName({ ...config, data_source_name: 'Some Data Source' }, client) | ||
| ).rejects.toThrowError( | ||
| 'To query from multiple data sources, first enable the data sources feature' |
There was a problem hiding this comment.
this also needs to fix as well, right? as per this commit a274600
| function throwWithCell(cell, exception) { | ||
| throw new Error(' in cell #' + (cell + 1) + ': ' + exception.message); | ||
| const e = new Error(exception.message); | ||
| e.name = `Expression parse error in cell #${cell + 1}`; |
There was a problem hiding this comment.
does the name field matter?
There was a problem hiding this comment.
Yes: server-side error messages are propagated to the client and the toast error message will show (this is existing behavior and UX is aligned). This is needed to make the toast more readable (stack information is kept hidden from client).
| config: OpenSearchFunctionConfig, | ||
| client: SavedObjectsClientContract | ||
| ) => { | ||
| if (config.data_source_name) { |
There was a problem hiding this comment.
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
* Add MDS support to Timeline Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Refactor to function and add unit tests Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Fix typo in args Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Refactor build request to pass unit tests Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Add to CHANGELOG Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Refactor error messages + address comments Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Fix ut Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Change to data source feature Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Fix UT Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Address comments Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> --------- Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> (cherry picked from commit 73e5d78) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md
* Add MDS support to Timeline Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Refactor to function and add unit tests Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Fix typo in args Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Refactor build request to pass unit tests Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Add to CHANGELOG Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Refactor error messages + address comments Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Fix ut Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Change to data source feature Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Fix UT Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Address comments Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> --------- Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> (cherry picked from commit 73e5d78) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: ZilongX <99905560+ZilongX@users.noreply.github.com>
Description
Previously, MDS did not support Timeline. This PR adds a new field
data_source_namesimilar to #5927 that enables users to specify a unique data source in which to query data from. This allows users to query from multiple indices and multiple data sources via the.opensearch()function.Issues Resolved
Closes #6009 and is related to #6410
Screenshot
Screen.Recording.2024-04-10.at.3.27.37.PM.mov
Testing the changes
If MDS is disabled:
data_source_namewill throw an error server-side and a toast message will be shown indicating that MDS is disabledIf MDS is enabled:
Source AandSource Bwere connecteddata_source_name="<data source name>"at the end of the.opensearch()expression. Order matters with Timeline expressions as arguments can be named or unnamed.Check List
yarn test:jestyarn test:jest_integration