Skip to content

ES|QL pattern formatting#222871

Merged
jgowdyelastic merged 67 commits intoelastic:mainfrom
jgowdyelastic:esql-pattern-formatting
Jun 25, 2025
Merged

ES|QL pattern formatting#222871
jgowdyelastic merged 67 commits intoelastic:mainfrom
jgowdyelastic:esql-pattern-formatting

Conversation

@jgowdyelastic
Copy link
Member

@jgowdyelastic jgowdyelastic commented Jun 5, 2025

Adds a recommended query for the CATEGORIZE function in ES|QL.
Adds keyword highlighting for the patterns and the ability to open a new Discover tab to filter for docs which match the selected pattern.

2025-06-19.16-55-20.2025-06-19.16_55_49.mp4
jgowdyelastic and others added 29 commits June 5, 2025 18:46
Copy link
Contributor

@ThomThomson ThomThomson left a comment

Choose a reason for hiding this comment

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

Unified search changes LGTM! Code only review

Copy link

@joana-cps joana-cps left a comment

Choose a reason for hiding this comment

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

The View matching results is also available in the count cell and it fails when I click on it. I think we should have this button in the pattern cell right?
Screenshot 2025-06-24 at 15 58 51
Screenshot 2025-06-24 at 15 58 10


@joana-cps Fixed in 4654f16

Copy link

@joana-cps joana-cps left a comment

Choose a reason for hiding this comment

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

Screenshot 2025-06-24 at 15 55 01
Should we limit the size of the popover? Looks a bit too much


@joana-cps I've added a maxWidth of 600px in b82feff

Copy link

@joana-cps joana-cps left a comment

Choose a reason for hiding this comment

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

When I change the display to one line, I can't see the ... at the end and the tokens get cut off.
Screenshot 2025-06-24 at 16 20 21
It works well with messages:
Screenshot 2025-06-24 at 16 22 53


@joana-cps Fixed in 892daf8

@jgowdyelastic jgowdyelastic requested a review from joana-cps June 24, 2025 14:29
Copy link

@joana-cps joana-cps left a comment

Choose a reason for hiding this comment

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

Design changes LGTM ✅
Left some comments that can be addressed in a different PR as bug fixes


const FIELD_PRIORITY = ['message', 'error.message', 'event.original'];

const METADATA_FIELDS = [
Copy link
Member

@qn895 qn895 Jun 24, 2025

Choose a reason for hiding this comment

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

Why not make this a set? So the METADATA_FIELDS array doesn't have be scanned every time we are checking the fields.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, good suggestion.

const buttons = await popover.findAllByTagName('button');
expect(buttons.length).to.eql(4);
// Click the last button which is the "View docs in Discover" button
await buttons[3].click();
Copy link
Member

Choose a reason for hiding this comment

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

For future follow up: Is there a way to grab this button by ID instead of the order? There's a chance there will be more options added in the future in this popover, so suggestion to find maybe by ID or something more unique.

Copy link
Member Author

Choose a reason for hiding this comment

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

The data-test-subj has an ID appended to it, I couldn't work out how to know what this will be, so I went with the count of buttons instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

We use this method in the dataGrid FTR service, which ignores the appended ID:

public async clickCellExpandPopoverAction(cellActionId: string) {
await this.testSubjects.click(`*dataGridColumnCellAction-${cellActionId}`);
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed in e697375

Copy link
Member

@qn895 qn895 left a comment

Choose a reason for hiding this comment

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

Left few comments for future follow up but LGTM 🎉

Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

Just leaving a couple more quick comments, but again nothing that should block merging this.

const discoverLocator = services.share?.url.locators.get('DISCOVER_APP_LOCATOR');
const discoverLink = discoverLocator?.getRedirectUrl({
query,
timeRange: services.data.query.timefilter.timefilter.getTime(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh interesting, we'll have to fix that on our end then. In that case you're good to keep using timefilter if you'd like and we can adjust it later. It has no impact for now anyway, just hoping to at some point migrate away from the global services for some future plans we have.

const buttons = await popover.findAllByTagName('button');
expect(buttons.length).to.eql(4);
// Click the last button which is the "View docs in Discover" button
await buttons[3].click();
Copy link
Contributor

Choose a reason for hiding this comment

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

We use this method in the dataGrid FTR service, which ignores the appended ID:

public async clickCellExpandPopoverAction(cellActionId: string) {
await this.testSubjects.click(`*dataGridColumnCellAction-${cellActionId}`);
}

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

This looks great, I added 2 additional comments that I prefer to be handled in this PR. They should be super small. I will approve immediately after!

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

ES|QL code changes LGTM! I also tested it locally and works great 🥳 Thanx James!

@jgowdyelastic jgowdyelastic enabled auto-merge (squash) June 25, 2025 09:09
@jgowdyelastic jgowdyelastic merged commit 0d2930b into elastic:main Jun 25, 2025
13 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19

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

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #110 / Cloud Security Posture Test adding Cloud Security Posture Integrations CSPM AWS CIS_AWS Organization Manual Direct Access CIS_AWS Organization Manual Direct Access Workflow

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
aiops 610 612 +2
discover 1333 1337 +4
unifiedSearch 369 371 +2
total +8

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-validation-autocomplete 168 169 +1

Async chunks

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

id before after diff
aiops 509.3KB 509.0KB -289.0B
dataVisualizer 681.3KB 680.0KB -1.3KB
discover 1.1MB 1.1MB +6.2KB
unifiedSearch 335.1KB 336.1KB +983.0B
total +5.5KB

Page load bundle

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

id before after diff
dataVisualizer 26.2KB 26.3KB +31.0B
discover 21.9KB 21.9KB +3.0B
kbnUiSharedDeps-srcJs 3.7MB 3.7MB +772.0B
total +806.0B
Unknown metric groups

API count

id before after diff
@kbn/aiops-utils - 4 +4
@kbn/esql-utils 114 116 +2
@kbn/esql-validation-autocomplete 191 192 +1
total +7

async chunk count

id before after diff
dataVisualizer 19 20 +1

References to deprecated APIs

id before after diff
@kbn/esql-utils 30 31 +1

History

cc @jgowdyelastic

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.19 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 222871

Questions ?

Please refer to the Backport tool documentation

@jgowdyelastic
Copy link
Member Author

💚 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

jgowdyelastic added a commit to jgowdyelastic/kibana that referenced this pull request Jun 25, 2025
Adds a recommended query for the `CATEGORIZE` function in ES|QL.
Adds keyword highlighting for the patterns and the ability to open a new
Discover tab to filter for docs which match the selected pattern.

https://github.com/user-attachments/assets/9ed8c5b0-7e92-4cc8-88dd-cb7749b5ffd3

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
(cherry picked from commit 0d2930b)

# Conflicts:
#	.github/CODEOWNERS
#	src/platform/packages/shared/kbn-esql-validation-autocomplete/src/autocomplete/recommended_queries/templates.ts
#	src/platform/plugins/shared/discover/public/application/main/hooks/use_esql_mode.test.tsx
#	src/platform/plugins/shared/discover/public/application/main/state_management/discover_app_state_container.ts
#	src/platform/plugins/shared/discover/public/application/main/state_management/discover_data_state_container.test.ts
#	src/platform/plugins/shared/discover/public/application/main/state_management/discover_data_state_container.ts
#	src/platform/plugins/shared/discover/public/application/main/state_management/utils/build_esql_fetch_subscribe.ts
#	src/platform/plugins/shared/discover/public/application/main/state_management/utils/change_data_view.ts
jgowdyelastic added a commit that referenced this pull request Jun 25, 2025
# Backport

This will backport the following commits from `main` to `8.19`:
- [ES|QL pattern formatting
(#222871)](#222871)

<!--- Backport version: 10.0.1 -->

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

<!--BACKPORT [{"author":{"name":"James
Gowdy","email":"jgowdy@elastic.co"},"sourceCommit":{"committedDate":"2025-06-25T10:33:30Z","message":"ES|QL
pattern formatting (#222871)\n\nAdds a recommended query for the
`CATEGORIZE` function in ES|QL.\nAdds keyword highlighting for the
patterns and the ability to open a new\nDiscover tab to filter for docs
which match the selected
pattern.\n\n\nhttps://github.com/user-attachments/assets/9ed8c5b0-7e92-4cc8-88dd-cb7749b5ffd3\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Stratoula Kalafateli
<efstratia.kalafateli@elastic.co>","sha":"0d2930b3d0ac8e8f77d491128a56239efeb947b6","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","Feature:Discover",":ml","Feature:ML/AIOps","backport:version","v9.1.0","v8.19.0"],"title":"ES|QL
pattern
formatting","number":222871,"url":"https://github.com/elastic/kibana/pull/222871","mergeCommit":{"message":"ES|QL
pattern formatting (#222871)\n\nAdds a recommended query for the
`CATEGORIZE` function in ES|QL.\nAdds keyword highlighting for the
patterns and the ability to open a new\nDiscover tab to filter for docs
which match the selected
pattern.\n\n\nhttps://github.com/user-attachments/assets/9ed8c5b0-7e92-4cc8-88dd-cb7749b5ffd3\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Stratoula Kalafateli
<efstratia.kalafateli@elastic.co>","sha":"0d2930b3d0ac8e8f77d491128a56239efeb947b6"}},"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/222871","number":222871,"mergeCommit":{"message":"ES|QL
pattern formatting (#222871)\n\nAdds a recommended query for the
`CATEGORIZE` function in ES|QL.\nAdds keyword highlighting for the
patterns and the ability to open a new\nDiscover tab to filter for docs
which match the selected
pattern.\n\n\nhttps://github.com/user-attachments/assets/9ed8c5b0-7e92-4cc8-88dd-cb7749b5ffd3\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
Stratoula Kalafateli
<efstratia.kalafateli@elastic.co>","sha":"0d2930b3d0ac8e8f77d491128a56239efeb947b6"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
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 Feature:Discover Discover Application Feature:ML/AIOps ML AIOps features: Change Point Detection, Log Pattern Analysis, Log Rate Analysis :ml release_note:enhancement v8.19.0 v9.1.0

10 participants