Skip to content

[POC] Grouping component in Discover#209047

Draft
YulNaumenko wants to merge 4 commits intoelastic:mainfrom
YulNaumenko:discover-grouping-poc
Draft

[POC] Grouping component in Discover#209047
YulNaumenko wants to merge 4 commits intoelastic:mainfrom
YulNaumenko:discover-grouping-poc

Conversation

@YulNaumenko
Copy link
Copy Markdown
Contributor

@YulNaumenko YulNaumenko commented Jan 31, 2025

Summary

This PR is a POC demonstrating, that integrating @kbn/grouping component is pretty simple and not specific to alerting.
Grouping component is configurable for all Data Views and could be very helpful in the data exploration process.
Short Demo:

Screen.Recording.2025-01-30.at.7.45.35.PM.mov

Diagram:

Screenshot 2025-01-30 at 8 17 14 PM

@YulNaumenko YulNaumenko self-assigned this Jan 31, 2025
@YulNaumenko YulNaumenko requested review from a team as code owners January 31, 2025 03:39
@YulNaumenko YulNaumenko marked this pull request as draft January 31, 2025 03:40
@elasticmachine
Copy link
Copy Markdown
Contributor

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!

@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Jan 31, 2025

💔 Build Failed

Failed CI Steps

History

cc @YulNaumenko

eokoneyo added a commit that referenced this pull request Jan 23, 2026
## Summary

This PR builds on prior art
#209047, to bring grouped data
(named cascade) exploration to discover for ES|QL.

When a user inputs any ES|QL query; said query will be parsed, on
parsing said inputted query if an occurrence of the
[`STATS`](https://www.elastic.co/docs/reference/query-languages/esql/commands/stats-by)
command is found it would trigger the possibility of having a different
view; the grouped view.

However this experience is not necessarily what the user would always
have, the heuristics for being presented the cascade experience are as
follows;

- The user inputted an ES|QL query that includes the target command (i.e
`STATS`)
- The feature flag for the cascade experience is enabled
- The user has not specifically chosen to opt out from the cascade
experience.

That being said, given the following valid query including a `STATS`
command;

```esql
FROM kibana_sample_data_logs
  | KEEP bytes, clientip, url.keyword, response.keyword
  | STATS Visits = COUNT(), Unique = COUNT_DISTINCT(clientip),
      p95 = PERCENTILE(bytes, 95), median = MEDIAN(bytes)
        BY url.keyword
  | LIMIT 123
```

The user would be presented with a combobox alongs side the regular
document options, that allows the user to select at this time an option
to group by the field which the user grouped the STATS query by or a
choice to revert to the regular view.

It's worth mentioning that in the event that the user provides a query
that specifies more than one grouping, for example;

```esql
FROM kibana_sample_data_logs
  | KEEP bytes, clientip, url.keyword, response.keyword
  | STATS Visits = COUNT(), Unique = COUNT_DISTINCT(clientip),
      p95 = PERCENTILE(bytes, 95), median = MEDIAN(bytes)
        BY bytes, clientip, url.keyword, response.keyword
  | LIMIT 123
```

We'd revert to the regular view the user is familiar with.

A note on how groups are selected; all referenced columns that exist on
the record from the last `STATS` command are selected by default as data
pivot option, whilst STATS also supports the
[`BUCKET`](https://www.elastic.co/docs/reference/query-languages/esql/functions-operators/grouping-functions#esql-bucket),
[`TBUCKET`](https://www.elastic.co/docs/reference/query-languages/esql/functions-operators/grouping-functions#esql-tbucket)
and
[`CATEGORIZE`](https://www.elastic.co/docs/reference/query-languages/esql/functions-operators/grouping-functions#esql-categorize)
grouping functions, at this time this implementation will only provide
pivot points for the `CATEGORIZE` grouping function.
 

## How to test

- Add the config `feature_flags.overrides.discover.cascadeLayoutEnabled:
true` in your `kibana.dev.yml`
- install your data of choice, for the sake of this guide the
`kibana_sample_data_logs` sample data is sufficient.
- Navigate to discover, select the button that prompts to "Tryout ES|QL"
- Input the query from above or a different one, and you should be
presented with the cascade experience similar to the screen recording
below;



https://github.com/user-attachments/assets/c3931adf-d88e-4369-b304-1bc2635b9182

	

### Checklist

Reviewers should verify this PR satisfies this list as well.

- [x] 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
- [x] [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
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)


<!--
### Identify risks

Does this PR introduce any risks? For example, consider risks like hard
to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging.

- [ ] [See some risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
- [ ] ...
-->

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Ryan Keairns <contactryank@gmail.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Davis McPhee <davis.mcphee@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants