ES|QL pattern formatting#222871
Conversation
…bana into esql-pattern-formatting
…bana into esql-pattern-formatting
...iscover/public/context_awareness/profile_providers/common/patterns/pattern_cell_renderer.tsx
Outdated
Show resolved
Hide resolved
ThomThomson
left a comment
There was a problem hiding this comment.
Unified search changes LGTM! Code only review
There was a problem hiding this comment.
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?


@joana-cps Fixed in 4654f16
There was a problem hiding this comment.

Should we limit the size of the popover? Looks a bit too much
@joana-cps I've added a maxWidth of 600px in b82feff
There was a problem hiding this comment.
When I change the display to one line, I can't see the ... at the end and the tokens get cut off.

It works well with messages:

@joana-cps Fixed in 892daf8
joana-cps
left a comment
There was a problem hiding this comment.
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 = [ |
There was a problem hiding this comment.
Why not make this a set? So the METADATA_FIELDS array doesn't have be scanned every time we are checking the fields.
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
We use this method in the dataGrid FTR service, which ignores the appended ID:
kibana/src/platform/test/functional/services/data_grid.ts
Lines 246 to 248 in dd29b09
qn895
left a comment
There was a problem hiding this comment.
Left few comments for future follow up but LGTM 🎉
davismcphee
left a comment
There was a problem hiding this comment.
Just leaving a couple more quick comments, but again nothing that should block merging this.
...iscover/public/context_awareness/profile_providers/common/patterns/pattern_cell_renderer.tsx
Outdated
Show resolved
Hide resolved
| const discoverLocator = services.share?.url.locators.get('DISCOVER_APP_LOCATOR'); | ||
| const discoverLink = discoverLocator?.getRedirectUrl({ | ||
| query, | ||
| timeRange: services.data.query.timefilter.timefilter.getTime(), |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
We use this method in the dataGrid FTR service, which ignores the appended ID:
kibana/src/platform/test/functional/services/data_grid.ts
Lines 246 to 248 in dd29b09
...lugins/shared/discover/public/context_awareness/profile_providers/common/patterns/profile.ts
Outdated
Show resolved
Hide resolved
stratoula
left a comment
There was a problem hiding this comment.
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!
.../shared/kbn-esql-validation-autocomplete/src/autocomplete/recommended_queries/suggestions.ts
Outdated
Show resolved
Hide resolved
...lugins/shared/discover/public/context_awareness/profile_providers/common/patterns/profile.ts
Outdated
Show resolved
Hide resolved
stratoula
left a comment
There was a problem hiding this comment.
ES|QL code changes LGTM! I also tested it locally and works great 🥳 Thanx James!
|
Starting backport for target branches: 8.19 |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
async chunk count
References to deprecated APIs
History
|
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
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
# 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>
Adds a recommended query for the
CATEGORIZEfunction 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