Skip to content

Register recommended ES|QL queries for Observability#224054

Merged
gbamparop merged 11 commits intoelastic:mainfrom
gbamparop:obs-esql-recommended-queries
Jun 23, 2025
Merged

Register recommended ES|QL queries for Observability#224054
gbamparop merged 11 commits intoelastic:mainfrom
gbamparop:obs-esql-recommended-queries

Conversation

@gbamparop
Copy link
Contributor

@gbamparop gbamparop commented Jun 16, 2025

Summary

This PRs builds on top of the extension point added to the E|QL editor by registering recommended ES|QL queries from the Observability plugin.

It registers two recommended queries for logs and two for metrics:

  • Kubernetes pods sorted by memory usage
  • Kubernetes pods sorted by CPU usage
  • Logs with "error" or "warn" messages
  • Error occurrences by host name

Demo - Solution navigation enabled

Screen.Recording.2025-06-16.at.12.16.12.mov

Demo - Solution navigation disabled

Only the default recommended ES|QL queries are enabled in this mode.

Screen.Recording.2025-06-16.at.12.16.12.mov

Testing instructions

There is an environment deployed with /oblt-deploy that has logs and metrics (check last month in Discover), you can find the credentials in the issue posted by the bot in the issue timeline below

For local testing:

  • Ingest logs and metrics. This can be done by running a Synthtrace scenario, e.g. node scripts/synthtrace.js logs_traces_hosts
  • Enable the Observability solution navigation
  • Start writing an ES|QL query targeting indices that match the logs-* or metrics-* patterns

Open questions

  • Should the KQL command be used in the queries?

Closes #224027

@gbamparop
Copy link
Contributor Author

/oblt-deploy

@gbamparop
Copy link
Contributor Author

gbamparop commented Jun 16, 2025

@stratoula the first time a description is accessed from the popup, the height is not being set correctly. Is this something that could be addressed? You can see the first demo video above.

Also, the description popup is turned off by default right?

image

@gbamparop
Copy link
Contributor Author

/ci

@gbamparop
Copy link
Contributor Author

@elasticmachine merge upstream

@gbamparop
Copy link
Contributor Author

/ci

@gbamparop gbamparop added backport:version Backport to applied version labels v9.1.0 v8.19.0 release_note:skip Skip the PR/issue when compiling release notes labels Jun 16, 2025
@gbamparop
Copy link
Contributor Author

/ci

},
{
name: 'Logs with "error" or "warn" messages',
query: 'FROM logs-* | WHERE KQL("message:error or message:warn")',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative to a hardcoded logs-* pattern could be to use the log source settings, but it's provided by the start contract https://github.com/gbamparop/kibana/blob/main/x-pack/platform/plugins/shared/logs_data_access/server/plugin.ts#L41.

@stratoula
Copy link
Contributor

I have never seen this. Which browser r u? 🤔

And yes it is off and it can't change

@gbamparop
Copy link
Contributor Author

gbamparop commented Jun 16, 2025

I have never seen this. Which browser r u? 🤔

Chrome 137.0.7151.104.

@stratoula
Copy link
Contributor

I can't replicate but they look great 👏

image

@gbamparop gbamparop marked this pull request as ready for review June 17, 2025 08:03
@gbamparop gbamparop requested review from a team as code owners June 17, 2025 08:03
@gbamparop
Copy link
Contributor Author

gbamparop commented Jun 17, 2025

@stratoula replicated it in Safari too. Btw it only happens the first time a description is opened by clicking at the arrow, then the height is set correctly.

image

@stratoula
Copy link
Contributor

stratoula commented Jun 17, 2025

Interesting, this is a monaco builtin functionality. Not sure why it appears like that in you 🤔 My safari works great too. Is it only the first one?

Maybe we can use the same pattern we use in ECS fields. Small title, big description. Does it also happens to you when you open an ECS field?

@stratoula
Copy link
Contributor

@gbamparop can you check with these changes #224195 if you still see a problem? #224195

@botelastic botelastic bot added the Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. label Jun 17, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

@iblancof
Copy link
Contributor

iblancof commented Jun 17, 2025

Should the KQL command be used in the queries?

I was going through the code and wondered why KQL is being used in some of the queries.

On my side, I'm working on adding a few queries for APM too, and I noticed that ES|QL is much stricter with field names compared to classic mode. So, if a query in ES|QL references a field that doesn't exist in the queried indexes, it throws an error, whereas wrapping the condition in KQL avoids that issue.

Maybe there’s a way to bypass this in ES|QL, but I’m not aware of it. That’s why I’m asking, in the case of logs, is KQL being used for this reason, or was there another consideration behind that decision?

@gbamparop
Copy link
Contributor Author

Maybe there’s a way to bypass this in ES|QL, but I’m not aware of it. That’s why I’m asking, in the case of logs, is KQL being used for this reason, or was there another consideration behind that decision?

This is what we were trying to figure out when we discussed it with @LucaWintergerst . @ninoslavmiskovic suggested to explore the use of QSTR or MATCH. @flash1293 do you have any thoughts?

@gbamparop
Copy link
Contributor Author

@gbamparop can you check with these changes #224195 if you still see a problem? #224195

@stratoula as discussed over Slack, they issue still remains with the latest changes.

@gbamparop
Copy link
Contributor Author

@gbamparop I think that it would be better to use MATCH or QSTR or the match operator (:) than KQL to promote the ES search functions instead

Agree, @LucaWintergerst do you have any preference between the two? Please note that as Irene mentioned above, MATCH throws an error if a field doesn't exist. Since they're recommended queries and users might not have experience with ES|QL at all, I'd go for QSTR.

Screen.Recording.2025-06-17.at.16.32.09.mov

@ninoslavmiskovic
Copy link
Contributor

@stratoula I mentioned the same to @gbamparop and maybe we can update them once we have the field context logic ready to not increase erroring out. WDYT ?

@stratoula
Copy link
Contributor

if it doesn't fail in the full text search query it will fail later if the fields do not exist. So I am not sure that picking qstr in favor of match etc is solving the field existence problem.

@iblancof
Copy link
Contributor

if it doesn't fail in the full text search query it will fail later if the fields do not exist. So I am not sure that picking qstr in favor of match etc is solving the field existence problem.

In my team's specific case, QSTR does seem to solve the problem for us, since we want to use a query FROM traces-* that can work with mixed data using either the ECS or the OTel schema.

@stratoula
Copy link
Contributor

I am talking abut a case like that:

from index | where qstr(not_existing_field: meow) | stats count() by not_existin_field2

My point is that you might overpass this with QSTR but if you use a non existent field elsewhere in the query, the query will fail

Copy link
Contributor

@achyutjhunjhunwala achyutjhunjhunwala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the KQL discussion which is already going on. rest looks good

Thank you for adding this.

@gbamparop
Copy link
Contributor Author

@elasticmachine merge upstream


const OBS_ESQL_RECOMMENDED_QUERIES = [
{
name: 'Kubernetes pods sorted by memory usage',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we use i18n for translations in name and description?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, added in 5bd7780

@gbamparop
Copy link
Contributor Author

Synced with Luca offline and replaced KQL with QSTR.

@gbamparop
Copy link
Contributor Author

@elasticmachine merge upstream

defaultMessage: 'Logs with "error" or "warn" messages',
}),
query: 'FROM logs-* | WHERE KQL("message:error or message:warn")',
query: 'FROM logs-* | WHERE QSTR("message:error or message:warn")',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gbamparop the or here should be OR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot, changed it in 8c66132

Copy link
Contributor

@fkanout fkanout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review only. LGTM

@gbamparop gbamparop enabled auto-merge (squash) June 23, 2025 10:30
@gbamparop gbamparop merged commit 3a23553 into elastic:main Jun 23, 2025
10 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19

https://github.com/elastic/kibana/actions/runs/15823789676

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Jun 23, 2025
## Summary
This PRs builds on top of the [extension point added to the E|QL
editor](elastic#221474) by registering
recommended ES|QL queries from the Observability plugin.

It registers two recommended queries for logs and two for metrics:
- Kubernetes pods sorted by memory usage
- Kubernetes pods sorted by CPU usage
- Logs with "error" or "warn" messages
- Error occurrences by host name

### Demo - Solution navigation enabled

https://github.com/user-attachments/assets/ca06b89b-5574-4775-8beb-157fa1eaa97a

### Demo - Solution navigation disabled
Only the default recommended ES|QL queries are enabled in this mode.

https://github.com/user-attachments/assets/52043076-6467-44fa-a847-937d3e723afc

## Testing instructions
There is an environment deployed with `/oblt-deploy` that has logs and
metrics (check last month in Discover), you can find the credentials in
the issue posted by the bot in the issue timeline below

For local testing:
- Ingest logs and metrics. This can be done by running a Synthtrace
scenario, e.g. `node scripts/synthtrace.js logs_traces_hosts`
- Enable the Observability solution navigation
- Start writing an ES|QL query targeting indices that match the `logs-*`
or `metrics-*` patterns

## Open questions
- Should the `KQL` command be used in the queries?

Closes elastic#224027

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 3a23553)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Jun 23, 2025
…#224861)

# Backport

This will backport the following commits from `main` to `8.19`:
- [Register recommended ES|QL queries for Observability
(#224054)](#224054)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Giorgos
Bamparopoulos","email":"georgios.bamparopoulos@elastic.co"},"sourceCommit":{"committedDate":"2025-06-23T12:08:18Z","message":"Register
recommended ES|QL queries for Observability (#224054)\n\n##
Summary\nThis PRs builds on top of the [extension point added to the
E|QL\neditor](#221474) by
registering\nrecommended ES|QL queries from the Observability
plugin.\n\nIt registers two recommended queries for logs and two for
metrics:\n- Kubernetes pods sorted by memory usage\n- Kubernetes pods
sorted by CPU usage\n- Logs with \"error\" or \"warn\" messages\n- Error
occurrences by host name\n\n### Demo - Solution navigation
enabled\n\nhttps://github.com/user-attachments/assets/ca06b89b-5574-4775-8beb-157fa1eaa97a\n\n###
Demo - Solution navigation disabled\nOnly the default recommended ES|QL
queries are enabled in this
mode.\n\n\nhttps://github.com/user-attachments/assets/52043076-6467-44fa-a847-937d3e723afc\n\n##
Testing instructions\nThere is an environment deployed with
`/oblt-deploy` that has logs and\nmetrics (check last month in
Discover), you can find the credentials in\nthe issue posted by the bot
in the issue timeline below\n\nFor local testing:\n- Ingest logs and
metrics. This can be done by running a Synthtrace\nscenario, e.g. `node
scripts/synthtrace.js logs_traces_hosts`\n- Enable the Observability
solution navigation\n- Start writing an ES|QL query targeting indices
that match the `logs-*`\nor `metrics-*` patterns\n\n## Open questions\n-
Should the `KQL` command be used in the queries?\n\nCloses
https://github.com/elastic/kibana/issues/224027\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"3a235538a01654b22ca9b177c5e6159ae7df588e","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:obs-ux-management","backport:version","v9.1.0","v8.19.0"],"title":"Register
recommended ES|QL queries for
Observability","number":224054,"url":"https://github.com/elastic/kibana/pull/224054","mergeCommit":{"message":"Register
recommended ES|QL queries for Observability (#224054)\n\n##
Summary\nThis PRs builds on top of the [extension point added to the
E|QL\neditor](#221474) by
registering\nrecommended ES|QL queries from the Observability
plugin.\n\nIt registers two recommended queries for logs and two for
metrics:\n- Kubernetes pods sorted by memory usage\n- Kubernetes pods
sorted by CPU usage\n- Logs with \"error\" or \"warn\" messages\n- Error
occurrences by host name\n\n### Demo - Solution navigation
enabled\n\nhttps://github.com/user-attachments/assets/ca06b89b-5574-4775-8beb-157fa1eaa97a\n\n###
Demo - Solution navigation disabled\nOnly the default recommended ES|QL
queries are enabled in this
mode.\n\n\nhttps://github.com/user-attachments/assets/52043076-6467-44fa-a847-937d3e723afc\n\n##
Testing instructions\nThere is an environment deployed with
`/oblt-deploy` that has logs and\nmetrics (check last month in
Discover), you can find the credentials in\nthe issue posted by the bot
in the issue timeline below\n\nFor local testing:\n- Ingest logs and
metrics. This can be done by running a Synthtrace\nscenario, e.g. `node
scripts/synthtrace.js logs_traces_hosts`\n- Enable the Observability
solution navigation\n- Start writing an ES|QL query targeting indices
that match the `logs-*`\nor `metrics-*` patterns\n\n## Open questions\n-
Should the `KQL` command be used in the queries?\n\nCloses
https://github.com/elastic/kibana/issues/224027\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"3a235538a01654b22ca9b177c5e6159ae7df588e"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/224054","number":224054,"mergeCommit":{"message":"Register
recommended ES|QL queries for Observability (#224054)\n\n##
Summary\nThis PRs builds on top of the [extension point added to the
E|QL\neditor](#221474) by
registering\nrecommended ES|QL queries from the Observability
plugin.\n\nIt registers two recommended queries for logs and two for
metrics:\n- Kubernetes pods sorted by memory usage\n- Kubernetes pods
sorted by CPU usage\n- Logs with \"error\" or \"warn\" messages\n- Error
occurrences by host name\n\n### Demo - Solution navigation
enabled\n\nhttps://github.com/user-attachments/assets/ca06b89b-5574-4775-8beb-157fa1eaa97a\n\n###
Demo - Solution navigation disabled\nOnly the default recommended ES|QL
queries are enabled in this
mode.\n\n\nhttps://github.com/user-attachments/assets/52043076-6467-44fa-a847-937d3e723afc\n\n##
Testing instructions\nThere is an environment deployed with
`/oblt-deploy` that has logs and\nmetrics (check last month in
Discover), you can find the credentials in\nthe issue posted by the bot
in the issue timeline below\n\nFor local testing:\n- Ingest logs and
metrics. This can be done by running a Synthtrace\nscenario, e.g. `node
scripts/synthtrace.js logs_traces_hosts`\n- Enable the Observability
solution navigation\n- Start writing an ES|QL query targeting indices
that match the `logs-*`\nor `metrics-*` patterns\n\n## Open questions\n-
Should the `KQL` command be used in the queries?\n\nCloses
https://github.com/elastic/kibana/issues/224027\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"3a235538a01654b22ca9b177c5e6159ae7df588e"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Giorgos Bamparopoulos <georgios.bamparopoulos@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
akowalska622 pushed a commit to akowalska622/kibana that referenced this pull request Jun 25, 2025
## Summary
This PRs builds on top of the [extension point added to the E|QL
editor](elastic#221474) by registering
recommended ES|QL queries from the Observability plugin.

It registers two recommended queries for logs and two for metrics:
- Kubernetes pods sorted by memory usage
- Kubernetes pods sorted by CPU usage
- Logs with "error" or "warn" messages
- Error occurrences by host name

### Demo - Solution navigation enabled

https://github.com/user-attachments/assets/ca06b89b-5574-4775-8beb-157fa1eaa97a

### Demo - Solution navigation disabled
Only the default recommended ES|QL queries are enabled in this mode.


https://github.com/user-attachments/assets/52043076-6467-44fa-a847-937d3e723afc

## Testing instructions
There is an environment deployed with `/oblt-deploy` that has logs and
metrics (check last month in Discover), you can find the credentials in
the issue posted by the bot in the issue timeline below

For local testing:
- Ingest logs and metrics. This can be done by running a Synthtrace
scenario, e.g. `node scripts/synthtrace.js logs_traces_hosts`
- Enable the Observability solution navigation
- Start writing an ES|QL query targeting indices that match the `logs-*`
or `metrics-*` patterns

## Open questions
- Should the `KQL` command be used in the queries?

Closes elastic#224027

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[One Discover] Add ES|QL recommended queries for Observability

10 participants