Skip to content

[ES|QL] [Discover] Keeps the histogram config on time change#208053

Merged
stratoula merged 10 commits intoelastic:mainfrom
stratoula:fix-keep-esql-chart-conf-on-time-change
Feb 3, 2025
Merged

[ES|QL] [Discover] Keeps the histogram config on time change#208053
stratoula merged 10 commits intoelastic:mainfrom
stratoula:fix-keep-esql-chart-conf-on-time-change

Conversation

@stratoula
Copy link
Copy Markdown
Contributor

@stratoula stratoula commented Jan 23, 2025

Summary

Closes #198749

meow

Checklist

return appendToESQLQuery(
safeQuery,
`| EVAL timestamp=DATE_TRUNC(${queryInterval}, ${dataView.timeFieldName}) | stats results = count(*) by timestamp${breakdown}${sortBy} | rename timestamp as \`${dataView.timeFieldName} every ${queryInterval}\``
`| EVAL timestamp=DATE_TRUNC(${queryInterval}, ${dataView.timeFieldName}) | stats results = count(*) by timestamp${breakdown}${sortBy}`
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ Remove the rename from here, let the lens suggestions api to handle this

Comment thread src/platform/plugins/shared/unified_histogram/public/services/lens_vis_service.ts Outdated
@stratoula stratoula added release_note:fix backport:version Backport to applied version labels v6.8.19 v8.18.0 v9.0.0 Feature:Discover Discover Application Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// and removed v6.8.19 labels Jan 24, 2025
@stratoula stratoula marked this pull request as ready for review January 24, 2025 11:20
@stratoula stratoula requested review from a team as code owners January 24, 2025 11:20
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@stratoula stratoula added the Feature:ES|QL ES|QL related features in Kibana label Jan 24, 2025
Copy link
Copy Markdown
Contributor

@jughosta jughosta left a comment

Choose a reason for hiding this comment

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

This is a very nice improvement to make!

Can you please check the case when user already had some Discover sessions with saved custom vis configuration? When I exported a session from another instance and imported it into an instance with this branch, my customization got reset.

return appendToESQLQuery(
safeQuery,
`| EVAL timestamp=DATE_TRUNC(${queryInterval}, ${dataView.timeFieldName}) | stats results = count(*) by timestamp${breakdown}${sortBy} | rename timestamp as \`${dataView.timeFieldName} every ${queryInterval}\``
`| EVAL timestamp=DATE_TRUNC(${queryInterval}, ${dataView.timeFieldName}) | stats results = count(*) by timestamp${breakdown}${sortBy}`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we exclude the time interval too? Otherwise, it stays locked when saved:

Screenshot 2025-01-24 at 13 52 31

Copy link
Copy Markdown
Contributor Author

@stratoula stratoula Jan 24, 2025

Choose a reason for hiding this comment

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

You mean when saved in a dashboard, right? Same problem exists in main too. If you save the histogram in the dashboard, the xaxis label doesnt change, the user needs to update the rename in the query.

Are you suggesting to exculde the label at all? To not mention the interval at all in the x axis?

Copy link
Copy Markdown
Contributor

@jughosta jughosta Jan 24, 2025

Choose a reason for hiding this comment

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

No exactly. In my case I saved the session + vis when my interval was 30 sec. Then I changed the time range to 1 year. The chart still shows "every 30 seconds". And it's also empty for some reason (as on the screenshot above).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hmm I can't reproduce. Here I have a discover session, I change the time and the label updates

meow

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you customize the chart before saving the session?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Have you made changes to your viz maybe and then saved? I think the problem is there. I will take a look to check if it is something easy to fix 👍

Copy link
Copy Markdown
Contributor

@jughosta jughosta Jan 24, 2025

Choose a reason for hiding this comment

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

Yeah, looks like it. Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This change should fix it a3e4495

@stratoula
Copy link
Copy Markdown
Contributor Author

Can you please check the case when user already had some Discover sessions with saved custom vis configuration? When I exported a session from another instance and imported it into an instance with this branch, my customization got reset.

Julia unfortunately is not going to work for existing saved searches because the SO has been saved with the name/id that has the timestamp with the interval.

columns: TextBasedLayerColumn[],
dateFieldLabel: string
) => {
const dateColumn = columns.find((column) => column.columnId === 'timestamp');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What if current data set has a real timestamp field, would not it conflict with this additional logic?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These are the columns used by the histogram and not the entire dataset, so this is the column we create with the eval

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Alright! Can we create a const for timestamp and share between files?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here it is Jul 84cef91

fieldName: c.variable ? `?${c.variable}` : c.id,
variable: c.variable,
label: c.name,
customLabel: c.id !== c.name,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can it be hasCustomLabel?

Noticed that the custom label gets reset when interval changes. Not sure if it's okay.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is an already existing property so I cant rename it unfortunately.

The custom label will reset here yes but I think that is ok as it happens only for the discover histogram. I dont expect users to want to give a custom label tbh. If we think that they need to, then we need to find another solution and not rely on the custom label of the Lens charts.

index: 'e3465e67bdeced2befff9f9dca7ecf9c48504cad68a10efd881f4c7dd5ade28a',
query: {
esql: 'from kibana_sample_data_logs | limit 10 | EVAL timestamp=DATE_TRUNC(30 second, @timestamp) | stats results = count(*) by timestamp | rename timestamp as `@timestamp every 30 second`',
esql: 'from kibana_sample_data_logs | limit 10 | EVAL timestamp=DATE_TRUNC(30 second, @timestamp) | stats results = count(*) by timestamp',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it correct that when adding to a dashboard, the chart does not show the same long time range?

Jan-27-2025 14-07-17

Copy link
Copy Markdown
Contributor Author

@stratoula stratoula Jan 27, 2025

Choose a reason for hiding this comment

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

This is happening also in main Julia. It is due to an ES limitation and irrelevant with this PR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hm, how do we have a different view on Discover page then?

Copy link
Copy Markdown
Contributor Author

@stratoula stratoula Jan 27, 2025

Choose a reason for hiding this comment

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

It seems so, not exactly sure why it looks differently in Discover though 🤔 . I was referring to this btw elastic/elasticsearch#111483

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since dashboard knows the current time range then it could pass it to Lens and it would be fixed on Dashboard page too even without ES support, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think the viz team wants to solve it when we have this elastic/elasticsearch#111483 from ES side. Right @markov00 ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's the idea, but this doesn't blocks us from specifying directly the timerange in the chart domain until this feature is available in ESQL

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes I agree, we should.

Copy link
Copy Markdown
Contributor

@jughosta jughosta left a comment

Choose a reason for hiding this comment

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

Data discovery changes LGTM 👍

Please note that this PR will reset existing customizations for ES|QL histogram which were saved in saved search SO.

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
lens 1.6MB 1.6MB +35.0B
unifiedHistogram 71.0KB 70.9KB -84.0B
total -49.0B

Page load bundle

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

id before after diff
unifiedHistogram 10.3KB 10.5KB +234.0B

History

Copy link
Copy Markdown
Contributor

@nickofthyme nickofthyme left a comment

Choose a reason for hiding this comment

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

Vis changes LGTM

@stratoula stratoula merged commit b25f236 into elastic:main Feb 3, 2025
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.18, 8.x, 9.0

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

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Feb 3, 2025
…#208053)

## Summary

Closes elastic#198749

![meow](https://github.com/user-attachments/assets/2cb2ff53-49f9-414e-985f-c0acd3945078)

### Checklist

- [ ] [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

(cherry picked from commit b25f236)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Feb 3, 2025
…#208053)

## Summary

Closes elastic#198749

![meow](https://github.com/user-attachments/assets/2cb2ff53-49f9-414e-985f-c0acd3945078)

### Checklist

- [ ] [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

(cherry picked from commit b25f236)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Feb 3, 2025
…#208053)

## Summary

Closes elastic#198749

![meow](https://github.com/user-attachments/assets/2cb2ff53-49f9-414e-985f-c0acd3945078)

### Checklist

- [ ] [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

(cherry picked from commit b25f236)
@kibanamachine
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
8.18
8.x
9.0

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 Feb 3, 2025
…208053) (#209357)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ES|QL] [Discover] Keeps the histogram config on time change
(#208053)](#208053)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Stratoula
Kalafateli","email":"efstratia.kalafateli@elastic.co"},"sourceCommit":{"committedDate":"2025-02-03T16:01:23Z","message":"[ES|QL]
[Discover] Keeps the histogram config on time change (#208053)\n\n##
Summary\n\nCloses
https://github.com/elastic/kibana/issues/198749\n\n\n![meow](https://github.com/user-attachments/assets/2cb2ff53-49f9-414e-985f-c0acd3945078)\n\n\n###
Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"b25f23674b0c01865f25e0633bd89731d063aaef","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Discover","release_note:fix","v9.0.0","Team:DataDiscovery","Feature:ES|QL","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[ES|QL]
[Discover] Keeps the histogram config on time
change","number":208053,"url":"https://github.com/elastic/kibana/pull/208053","mergeCommit":{"message":"[ES|QL]
[Discover] Keeps the histogram config on time change (#208053)\n\n##
Summary\n\nCloses
https://github.com/elastic/kibana/issues/198749\n\n\n![meow](https://github.com/user-attachments/assets/2cb2ff53-49f9-414e-985f-c0acd3945078)\n\n\n###
Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"b25f23674b0c01865f25e0633bd89731d063aaef"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/208053","number":208053,"mergeCommit":{"message":"[ES|QL]
[Discover] Keeps the histogram config on time change (#208053)\n\n##
Summary\n\nCloses
https://github.com/elastic/kibana/issues/198749\n\n\n![meow](https://github.com/user-attachments/assets/2cb2ff53-49f9-414e-985f-c0acd3945078)\n\n\n###
Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"b25f23674b0c01865f25e0633bd89731d063aaef"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
kibanamachine added a commit that referenced this pull request Feb 3, 2025
…208053) (#209356)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[ES|QL] [Discover] Keeps the histogram config on time change
(#208053)](#208053)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Stratoula
Kalafateli","email":"efstratia.kalafateli@elastic.co"},"sourceCommit":{"committedDate":"2025-02-03T16:01:23Z","message":"[ES|QL]
[Discover] Keeps the histogram config on time change (#208053)\n\n##
Summary\n\nCloses
https://github.com/elastic/kibana/issues/198749\n\n\n![meow](https://github.com/user-attachments/assets/2cb2ff53-49f9-414e-985f-c0acd3945078)\n\n\n###
Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"b25f23674b0c01865f25e0633bd89731d063aaef","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Discover","release_note:fix","v9.0.0","Team:DataDiscovery","Feature:ES|QL","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[ES|QL]
[Discover] Keeps the histogram config on time
change","number":208053,"url":"https://github.com/elastic/kibana/pull/208053","mergeCommit":{"message":"[ES|QL]
[Discover] Keeps the histogram config on time change (#208053)\n\n##
Summary\n\nCloses
https://github.com/elastic/kibana/issues/198749\n\n\n![meow](https://github.com/user-attachments/assets/2cb2ff53-49f9-414e-985f-c0acd3945078)\n\n\n###
Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"b25f23674b0c01865f25e0633bd89731d063aaef"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/208053","number":208053,"mergeCommit":{"message":"[ES|QL]
[Discover] Keeps the histogram config on time change (#208053)\n\n##
Summary\n\nCloses
https://github.com/elastic/kibana/issues/198749\n\n\n![meow](https://github.com/user-attachments/assets/2cb2ff53-49f9-414e-985f-c0acd3945078)\n\n\n###
Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"b25f23674b0c01865f25e0633bd89731d063aaef"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
kibanamachine added a commit that referenced this pull request Feb 3, 2025
…208053) (#209358)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[ES|QL] [Discover] Keeps the histogram config on time change
(#208053)](#208053)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Stratoula
Kalafateli","email":"efstratia.kalafateli@elastic.co"},"sourceCommit":{"committedDate":"2025-02-03T16:01:23Z","message":"[ES|QL]
[Discover] Keeps the histogram config on time change (#208053)\n\n##
Summary\n\nCloses
https://github.com/elastic/kibana/issues/198749\n\n\n![meow](https://github.com/user-attachments/assets/2cb2ff53-49f9-414e-985f-c0acd3945078)\n\n\n###
Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"b25f23674b0c01865f25e0633bd89731d063aaef","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Discover","release_note:fix","v9.0.0","Team:DataDiscovery","Feature:ES|QL","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[ES|QL]
[Discover] Keeps the histogram config on time
change","number":208053,"url":"https://github.com/elastic/kibana/pull/208053","mergeCommit":{"message":"[ES|QL]
[Discover] Keeps the histogram config on time change (#208053)\n\n##
Summary\n\nCloses
https://github.com/elastic/kibana/issues/198749\n\n\n![meow](https://github.com/user-attachments/assets/2cb2ff53-49f9-414e-985f-c0acd3945078)\n\n\n###
Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"b25f23674b0c01865f25e0633bd89731d063aaef"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/208053","number":208053,"mergeCommit":{"message":"[ES|QL]
[Discover] Keeps the histogram config on time change (#208053)\n\n##
Summary\n\nCloses
https://github.com/elastic/kibana/issues/198749\n\n\n![meow](https://github.com/user-attachments/assets/2cb2ff53-49f9-414e-985f-c0acd3945078)\n\n\n###
Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"b25f23674b0c01865f25e0633bd89731d063aaef"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

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:ES|QL ES|QL related features in Kibana release_note:fix Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// v8.18.0 v8.19.0 v9.0.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Discover][ES|QL] Brushing a timeseries should keep the preferred chart configuration

6 participants