Skip to content

[8.19] [ES|QL] Editor extensions registry - recommended queries (#221474)#222509

Merged
kibanamachine merged 4 commits intoelastic:8.19from
kibanamachine:backport/8.19/pr-221474
Jun 4, 2025
Merged

[8.19] [ES|QL] Editor extensions registry - recommended queries (#221474)#222509
kibanamachine merged 4 commits intoelastic:8.19from
kibanamachine:backport/8.19/pr-221474

Conversation

@kibanamachine
Copy link
Contributor

Backport

This will backport the following commits from main to 8.19:

Questions ?

Please refer to the Backport tool documentation

)

## Summary

Closes elastic#200026

### Scope

This PR is allowing the solutions teams to register extensions to the
editor. The first extension is **the recommended queries**. I prefer to
add extra extensions in follow up PRs mostly to keep it clean and also
because I want to see the usage first.

These extensions should not appear in the classic mode. They should
appear only on the solution that they are being registered for.

Some examples below:

- Only static suggestions, for index without solution extensions

<img width="913" alt="image"
src="https://github.com/user-attachments/assets/7fad3b42-3e03-43a6-91e6-6166337536ca"
/>

- Additional suggestions, for index with solution extensions

<img width="760" alt="image"
src="https://github.com/user-attachments/assets/0988c9f4-8986-4d45-a064-a536c71a690e"
/>

### Some more technical notes

- I am creating a server side registry in the esql plugin. I considered
to create a plugin from scratch but I decided against it as at this
point is only esql related extensions and we are trying to keep our
plugins number as low as possible. It can get moved to another plugin if
we ever decide in favor of it.
- Each solution can register in their plugins their extensions. I have
added a Readme which I hope it helps but this is how it should look

```
const esqlExtensionsRegistry = esql.getExtensionsRegistry();
        esqlExtensionsRegistry.setRecommendedQueries(
          [
            {
              name: 'Logs count by log level',
              query: 'from logs* | STATS count(*) by log_level',
            },
            {
              name: 'Apache logs counts',
              query: 'from logs-apache_error | STATS count(*)',
            },
            {
              name: 'Another index, not logs',
              query: 'from movies | STATS count(*)',
            },
          ],
            'oblt'
        );
```

- I preferred a server side registry for multiple reasons:
- In the case we want to make it more advanced in the future (more
checks, LLMs etc) it make more sense to have a server side solution
- It is more performant to do some checks such as (does this source
exist?) etc
- It allows me to create a route to get these extensions. I am using
this route to get the extensions to the editor but in the future we
could use the same route to display these extensions in a flyout or
wherever the solutions teams want

### Note
This PR is not registering anything at the editor but just sets up the
architecture. The registration of recommended queries should happen from
the solutions teams in their plugins.

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 0bba089)
@kibanamachine kibanamachine added the backport This PR is a backport of another PR label Jun 4, 2025
@kibanamachine kibanamachine enabled auto-merge (squash) June 4, 2025 07:58
@kibanamachine kibanamachine merged commit 74baeb6 into elastic:8.19 Jun 4, 2025
8 checks passed
@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #37 / alerting api integration security and spaces enabled - Group 2 Connectors ServiceNow ITOM ServiceNow ITOM - Executor Execution getChoices should get choices

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
esql 237 239 +2
stackAlerts 285 287 +2
total +4

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/esql-types 31 39 +8
@kbn/esql-validation-autocomplete 163 165 +2
@kbn/monaco 135 137 +2
esql 11 13 +2
total +14

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
esql 243.2KB 243.7KB +477.0B

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
esql 1 2 +1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
esql 9.0KB 9.5KB +509.0B
kbnUiSharedDeps-srcJs 3.6MB 3.6MB +651.0B
total +1.1KB
Unknown metric groups

API count

id before after diff
@kbn/esql-types 32 40 +8
@kbn/esql-validation-autocomplete 184 186 +2
@kbn/monaco 135 137 +2
esql 32 34 +2
total +14

History

cc @stratoula

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants