-
Notifications
You must be signed in to change notification settings - Fork 885
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
[MDS] Support for Timeline #6385
Conversation
Before rebase: |
src/plugins/vis_type_timeline/server/lib/fetch_data_source_id.test.ts
Outdated
Show resolved
Hide resolved
import { getDataSourceEnabled } from './services'; | ||
import { OpenSearchFunctionConfig } from '../types'; | ||
|
||
export const fetchDataSourceIdByName = async ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this user facing error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Timeline parses the expression
server-side and throws an Error if the expression
is incorrectly written. This will behave the same way.
src/plugins/vis_type_timeline/server/series_functions/opensearch/index.js
Show resolved
Hide resolved
/** | ||
* @deprecated The interval picker should be used instead | ||
*/ | ||
interval: string | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is meaning of comment? It is deprecated and we are still using it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
OpenSearch-Dashboards/src/plugins/vis_type_timeline/server/series_functions/opensearch/index.js
Lines 109 to 115 in 458501f
{ | |
name: 'interval', // You really shouldn't use this, use the interval picker instead | |
types: ['string', 'null'], | |
help: i18n.translate('timeline.help.functions.opensearch.args.intervalHelpText', { | |
defaultMessage: `**DO NOT USE THIS**. It's fun for debugging fit functions, but you really should use the interval picker`, | |
}), | |
}, |
/** | ||
* @deprecated The interval picker should be used instead | ||
*/ | ||
interval: string | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
import { getDataSourceEnabled } from './services'; | ||
import { OpenSearchFunctionConfig } from '../types'; | ||
|
||
export const fetchDataSourceIdByName = async ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: shouldn't be enable the data source feature
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this also needs to fix as well, right? as per this commit a274600
@@ -47,7 +47,9 @@ export default function chainRunner(tlConfig) { | |||
let sheet; | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the name field matter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored
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_name
similar 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_name
will throw an error server-side and a toast message will be shown indicating that MDS is disabledIf MDS is enabled:
Source A
andSource B
were 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:jest
yarn test:jest_integration