[ES|QL] [Discover] Keeps the histogram config on time change#208053
[ES|QL] [Discover] Keeps the histogram config on time change#208053stratoula merged 10 commits intoelastic:mainfrom
Conversation
| 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}` |
There was a problem hiding this comment.
ℹ️ Remove the rename from here, let the lens suggestions api to handle this
…lens_vis_service.ts
|
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
jughosta
left a comment
There was a problem hiding this comment.
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}` |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Can you customize the chart before saving the session?
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
Yeah, looks like it. Thanks!
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'); |
There was a problem hiding this comment.
What if current data set has a real timestamp field, would not it conflict with this additional logic?
There was a problem hiding this comment.
These are the columns used by the histogram and not the entire dataset, so this is the column we create with the eval
There was a problem hiding this comment.
Alright! Can we create a const for timestamp and share between files?
| fieldName: c.variable ? `?${c.variable}` : c.id, | ||
| variable: c.variable, | ||
| label: c.name, | ||
| customLabel: c.id !== c.name, |
There was a problem hiding this comment.
Can it be hasCustomLabel?
Noticed that the custom label gets reset when interval changes. Not sure if it's okay.
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
This is happening also in main Julia. It is due to an ES limitation and irrelevant with this PR
There was a problem hiding this comment.
Hm, how do we have a different view on Discover page then?
There was a problem hiding this comment.
It seems so, not exactly sure why it looks differently in Discover though 🤔 . I was referring to this btw elastic/elasticsearch#111483
There was a problem hiding this comment.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I think the viz team wants to solve it when we have this elastic/elasticsearch#111483 from ES side. Right @markov00 ?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
yes I agree, we should.
jughosta
left a comment
There was a problem hiding this comment.
Data discovery changes LGTM 👍
Please note that this PR will reset existing customizations for ES|QL histogram which were saved in saved search SO.
💚 Build Succeeded
Metrics [docs]Async chunks
Page load bundle
History
|
|
Starting backport for target branches: 8.18, 8.x, 9.0 |
…#208053) ## Summary Closes elastic#198749  ### 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)
…#208053) ## Summary Closes elastic#198749  ### 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)
…#208053) ## Summary Closes elastic#198749  ### 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)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…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\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\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\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>
…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\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\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\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>
…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\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\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\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>



Summary
Closes #198749
Checklist