Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[One Discover] Breakdown by log.level for logs sources #200584

Merged
merged 23 commits into from
Nov 28, 2024

Conversation

tonyghiani
Copy link
Contributor

@tonyghiani tonyghiani commented Nov 18, 2024

📓 Summary

Closes #183498

This work sets the Breakdown selector for the Histogram to the log.level field once a logs data source is resolved.
It also applies to ES|QL queries, the change is applied/removed on each source change.

@tonyghiani tonyghiani added release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Team:obs-ux-logs Observability Logs User Experience Team Project:OneDiscover Enrich Discover with contextual awareness labels Nov 18, 2024
@tonyghiani
Copy link
Contributor Author

/ci

@tonyghiani
Copy link
Contributor Author

/ci

@tonyghiani
Copy link
Contributor Author

/ci

@tonyghiani
Copy link
Contributor Author

/ci

@davismcphee
Copy link
Contributor

I opened a PR against this branch with fixes for the Discover issues here: tonyghiani#3.

cc @jughosta since it would be great to get your review on this after the PR merges to evaluate my changes. I also left some comments in the PR for reference.

@tonyghiani tonyghiani marked this pull request as ready for review November 22, 2024 13:25
@tonyghiani tonyghiani requested a review from a team as a code owner November 22, 2024 13:25
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-logs-team (Team:obs-ux-logs)

@tonyghiani
Copy link
Contributor Author

@davismcphee @jughosta the changes you applied fixed the initialization of the breakdown field 👌
It now works under a logical perspective, but (I guess) due to the internals of the discover state management, the UI flashes quite heavily when switching data view, probably cause it gets the newly resolved breakdown field and updates the state, which handles the loading for the histogram. I recorded a video, let me know if the issue is evident or we can look at it together.

Screen.Recording.2024-11-22.at.14.27.04.mov

@davismcphee
Copy link
Contributor

@tonyghiani Thanks for raising this, I was surprised to see it since I didn't think there should be an impact from these changes. Turns out this is actually an issue in main related to the Lens embeddable firing an extra pair of load/complete events before fetching now (but only actually fetches once). I haven't seen this bug before though so I wonder if it's recent and just snuck it's way in this PR with a merge from main.

The good news is the Lens embeddable refactor is merging soon, so I rebased these commits on it to test locally, and confirmed it doesn't have the bug:

data_view_2.mp4

Now I just need to figure out when the bug was merged to main and see if we need a fix backported...

@davismcphee
Copy link
Contributor

Ok I looked into it more and it's not an issue with the embeddable itself. It's because the embeddable is being unmounted and remounted here, which triggers an additional fetch, but it gets cancelled quickly so no request is actually sent:

if (!checkValidDataViewConfig(dataView, visContext, lensProps.attributes.state.adHocDataViews)) {
return <></>;
}

It looks like it was merged a couple of days ago in #200687, so still unrelated to this PR. And that code was removed in the embeddable refactor which explains why I didn't see it there.

cc @kertal, looks like the flaky test fix might have had some unintended effects. This is actually a good example of how manual control over Lens fetches would make our lives easier 😄

@tonyghiani
Copy link
Contributor Author

@davismcphee I see thanks! I'll wait for the work the lens embeddable to be merged and check for a last round if everything works correctly!

@kertal
Copy link
Member

kertal commented Nov 25, 2024

Ok I looked into it more and it's not an issue with the embeddable itself. It's because the embeddable is being unmounted and remounted here, which triggers an additional fetch, but it gets cancelled quickly so no request is actually sent:

if (!checkValidDataViewConfig(dataView, visContext, lensProps.attributes.state.adHocDataViews)) {
return <></>;
}

It looks like it was merged a couple of days ago in #200687, so still unrelated to this PR. And that code was removed in the embeddable refactor which explains why I didn't see it there.

cc @kertal, looks like the flaky test fix might have had some unintended effects. This is actually a good example of how manual control over Lens fetches would make our lives easier 😄

Yes, I think we should even consider to remove this "fix" of the backport, treat the occacional race condition and the one condition that we can reliably reproduce it, as a known issue. it's resolved in with the Lens embeddable 🥳

the interaction between Discover state <> Unified Histogram <> Lens embeddable produces unwanted side effects like in this case, that are resolved with #186642, and another argument for making our lives easier by gaining manual control over Lens embeddable data fetching 👍

@tonyghiani
Copy link
Contributor Author

@davismcphee the lens refactor is merged and I can confirm the glitch on the data fetching is gone, it looks good now! There were no additional change on my side, let me know whether we are good to go with this 👌

@jughosta
Copy link
Contributor

LGTM too 👍

@davismcphee
Copy link
Contributor

@tonyghiani Nice! It LGTM too, I just want to clarify a product question in Slack before merging.

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.

It looks like we're all in agreement from the product side to move forward, so in that case I'd say let's get this merged 👍 great work @tonyghiani!

@elasticmachine
Copy link
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
discover 810.1KB 811.3KB +1.2KB
unifiedHistogram 71.1KB 71.3KB +234.0B
total +1.4KB
Unknown metric groups

API count

id before after diff
unifiedHistogram 70 69 -1

History

cc @tonyghiani

@tonyghiani tonyghiani merged commit ac6025e into elastic:main Nov 28, 2024
8 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

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

@tonyghiani tonyghiani deleted the 183498-breakown-by-log-level branch November 28, 2024 08:13
@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.x Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 200584

Questions ?

Please refer to the Backport tool documentation

@tonyghiani
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

tonyghiani added a commit to tonyghiani/kibana that referenced this pull request Nov 28, 2024
## 📓 Summary

Closes elastic#183498

This work sets the Breakdown selector for the Histogram to the
`log.level` field once a logs data source is resolved.
It also applies to ES|QL queries, the change is applied/removed on each
source change.

---------

Co-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani@elastic.co>
Co-authored-by: Davis McPhee <davis.mcphee@elastic.co>
(cherry picked from commit ac6025e)

# Conflicts:
#	src/plugins/discover/public/application/main/state_management/discover_data_state_container.ts
#	src/plugins/discover/public/application/main/state_management/utils/change_data_view.ts
tonyghiani added a commit that referenced this pull request Nov 28, 2024
#202105)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[One Discover] Breakdown by log.level for logs sources
(#200584)](#200584)

<!--- Backport version: 8.9.8 -->

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

<!--BACKPORT [{"author":{"name":"Marco Antonio
Ghiani","email":"marcoantonio.ghiani01@gmail.com"},"sourceCommit":{"committedDate":"2024-11-28T08:12:47Z","message":"[One
Discover] Breakdown by log.level for logs sources (#200584)\n\n## 📓
Summary\r\n\r\nCloses #183498 \r\n\r\nThis work sets the Breakdown
selector for the Histogram to the\r\n`log.level` field once a logs data
source is resolved.\r\nIt also applies to ES|QL queries, the change is
applied/removed on each\r\nsource
change.\r\n\r\n---------\r\n\r\nCo-authored-by: Marco Antonio Ghiani
<marcoantonio.ghiani@elastic.co>\r\nCo-authored-by: Davis McPhee
<davis.mcphee@elastic.co>","sha":"ac6025eaa1b5e0e733bab0110b60928e27ee6860","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:DataDiscovery","backport:prev-minor","Team:obs-ux-logs","Project:OneDiscover"],"number":200584,"url":"https://github.com/elastic/kibana/pull/200584","mergeCommit":{"message":"[One
Discover] Breakdown by log.level for logs sources (#200584)\n\n## 📓
Summary\r\n\r\nCloses #183498 \r\n\r\nThis work sets the Breakdown
selector for the Histogram to the\r\n`log.level` field once a logs data
source is resolved.\r\nIt also applies to ES|QL queries, the change is
applied/removed on each\r\nsource
change.\r\n\r\n---------\r\n\r\nCo-authored-by: Marco Antonio Ghiani
<marcoantonio.ghiani@elastic.co>\r\nCo-authored-by: Davis McPhee
<davis.mcphee@elastic.co>","sha":"ac6025eaa1b5e0e733bab0110b60928e27ee6860"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200584","number":200584,"mergeCommit":{"message":"[One
Discover] Breakdown by log.level for logs sources (#200584)\n\n## 📓
Summary\r\n\r\nCloses #183498 \r\n\r\nThis work sets the Breakdown
selector for the Histogram to the\r\n`log.level` field once a logs data
source is resolved.\r\nIt also applies to ES|QL queries, the change is
applied/removed on each\r\nsource
change.\r\n\r\n---------\r\n\r\nCo-authored-by: Marco Antonio Ghiani
<marcoantonio.ghiani@elastic.co>\r\nCo-authored-by: Davis McPhee
<davis.mcphee@elastic.co>","sha":"ac6025eaa1b5e0e733bab0110b60928e27ee6860"}}]}]
BACKPORT-->
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
## 📓 Summary

Closes elastic#183498 

This work sets the Breakdown selector for the Histogram to the
`log.level` field once a logs data source is resolved.
It also applies to ES|QL queries, the change is applied/removed on each
source change.

---------

Co-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani@elastic.co>
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
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Project:OneDiscover Enrich Discover with contextual awareness release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. Team:obs-ux-logs Observability Logs User Experience Team v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[One Discover] Breakdown the unified histogram by log.level for logs data sources
6 participants