-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Elasticsearch: Fix query initialization logic & query transformation from Prometheus/Loki #31322
Conversation
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.
LGTM! I have tested Prom -> Elastic and Loki -> Elastic data source switch and it gave me correct query based on previous data source in both cases. I have also looked at older Elastic dashboards to see if there aren't any unexpected results, but all looked good. 👍 for adding and updating tests.
Good job. :)
importQueries(queries: DataQuery[], datasourceType: string): ElasticsearchQuery[] { | ||
if (datasourceType === 'prometheus' || datasourceType === 'loki') { | ||
return queries.map((query) => { | ||
let prometheusQuery: PromQuery = query as PromQuery; | ||
let prometheusQuery = query as PromQuery; | ||
const expr = getElasticsearchQuery(extractPrometheusLabels(prometheusQuery.expr)); | ||
return { | ||
isLogsQuery: true, |
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.
Do we still need isLogsQuery: true
if we are adding type: 'logs'
?
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 completely sure about it, i'm keeping it to avoid breaking anything, but for sure I'm gonna revisit it now with the BE refactoring. Thanks for pointing that out!
…from Promethous/Loki (#31322) * Elasticsearch: Fix query initialization logic * Only import prometheus & loki queries as log queries
What this PR does / why we need it:
Before the react refactoring, when switching from a prometheus or loki datasource to Elasticsearch in explore, we were generating logs query. While this was still happening, the new query initialization logic was overwriting those changes.
Additionally, everytime we were switching from ANY datasource to elasticsearch we were creating a log query, which is what most users probably want when switching from prometheus/loki, but not from other datasources.
Which issue(s) this PR fixes:
Fixes #31300
Special notes for your reviewer:
I changed a bit the initialization logic, this should be 100% compatible with what we had before, but it needs a bit of testing to be sure.
I'll also create an issue and a follow-up PR to add documentation for the "transform prometheus/loki query to elastic search query functionality"