[Obs AI Assistant] Skip log rate analysis and log categories when no entity filters are present - #290244
Conversation
|
Pinging @elastic/nightshift-context-and-research-team (Team:nightshift-context-and-research) |
There was a problem hiding this comment.
The fix is correct and correctly scoped: hasEntityFilters gates the two log-source fetchers using the same four entities they receive, which prevents the unbounded log-source fan-out when the alert has no entity context. One non-blocking note left inline regarding regression coverage for the fix.
Generated by Claude Reviewer for #290244 · claude · opus · 117.6 AIC · ⌖ 31.1 AIC · ⊞ 5.5K
jennypavlova
left a comment
There was a problem hiding this comment.
Thanks for the fix! As I mentioned in Slack I would add a test for that to help us find regressions easier in the future, wdyt?
|
@jennypavlova, thanks for the review. I added the regression tests. |
jennypavlova
left a comment
There was a problem hiding this comment.
LGTM! Thanks for adding the tests :)
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]
History
|
|
Starting backport for target branches: 8.19, 9.4, 9.5 |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
Update the "no params" case to expect an empty context, matching the hasEntityFilters gate added in #290244. Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Update the "no params" test to match the contract from #290244: with no entity filters, no log categories are returned. Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
…en no entity filters are present (#290244) (#290486) # Backport This will backport the following commits from `main` to `9.5`: - [[Obs AI Assistant] Skip log rate analysis and log categories when no entity filters are present (#290244)](#290244) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Arturo Lidueña","email":"arturo.liduena@elastic.co"},"sourceCommit":{"committedDate":"2026-09-11T09:27:57Z","message":"[Obs AI Assistant] Skip log rate analysis and log categories when no entity filters are present (#290244)\n\nCloses Issue: https://github.com/elastic/sdh-kibana/issues/6510\n\n## Summary\n\nFixes a performance issue where clicking \"Help me understand this alert\"\non a `custom_threshold` alert that monitors a non-standard metric, one\nthat produces no `service.name`, `host.name`, `container.id`, or\n`kubernetes.pod.name` in the alert document, causes the\n`/internal/observability/assistant/alert_details_contextual_insights`\nendpoint to hang indefinitely.\n\n### Root cause\n`getLogRateAnalysisForAlert` and `getLogCategories` were pushed to the\ndata-fetcher queue unconditionally, regardless of whether any entity\ncontext was available. When all entity values are `undefined`,\n`getShouldMatchOrNotExistFilter` returns an empty array, so the\nresulting ES queries carry no entity-scoping filters and fan out across\n**all** configured log sources.\n\n### Fix\nAdded a `hasEntityFilters` flag (true when at least one of\n`serviceName`, `hostName`, `containerId`, `kubernetesPodName` is\ndefined) and wrapped both log data fetchers with `if\n(hasEntityFilters)`. When no entity context is present, running these\nanalyses has no meaningful scope and would scan all log data without\ncorrelation to the triggering alert.","sha":"384373226111f1aaf3369363ee97eedd803c3ac4","branchLabelMapping":{"^v9.6.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","backport:all-open","v9.6.0","Team:nightshift-context-and-research","Team:obs-signals-traces"],"title":"[Obs AI Assistant] Skip log rate analysis and log categories when no entity filters are present","number":290244,"url":"https://github.com/elastic/kibana/pull/290244","mergeCommit":{"message":"[Obs AI Assistant] Skip log rate analysis and log categories when no entity filters are present (#290244)\n\nCloses Issue: https://github.com/elastic/sdh-kibana/issues/6510\n\n## Summary\n\nFixes a performance issue where clicking \"Help me understand this alert\"\non a `custom_threshold` alert that monitors a non-standard metric, one\nthat produces no `service.name`, `host.name`, `container.id`, or\n`kubernetes.pod.name` in the alert document, causes the\n`/internal/observability/assistant/alert_details_contextual_insights`\nendpoint to hang indefinitely.\n\n### Root cause\n`getLogRateAnalysisForAlert` and `getLogCategories` were pushed to the\ndata-fetcher queue unconditionally, regardless of whether any entity\ncontext was available. When all entity values are `undefined`,\n`getShouldMatchOrNotExistFilter` returns an empty array, so the\nresulting ES queries carry no entity-scoping filters and fan out across\n**all** configured log sources.\n\n### Fix\nAdded a `hasEntityFilters` flag (true when at least one of\n`serviceName`, `hostName`, `containerId`, `kubernetesPodName` is\ndefined) and wrapped both log data fetchers with `if\n(hasEntityFilters)`. When no entity context is present, running these\nanalyses has no meaningful scope and would scan all log data without\ncorrelation to the triggering alert.","sha":"384373226111f1aaf3369363ee97eedd803c3ac4"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.6.0","branchLabelMappingKey":"^v9.6.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/290244","number":290244,"mergeCommit":{"message":"[Obs AI Assistant] Skip log rate analysis and log categories when no entity filters are present (#290244)\n\nCloses Issue: https://github.com/elastic/sdh-kibana/issues/6510\n\n## Summary\n\nFixes a performance issue where clicking \"Help me understand this alert\"\non a `custom_threshold` alert that monitors a non-standard metric, one\nthat produces no `service.name`, `host.name`, `container.id`, or\n`kubernetes.pod.name` in the alert document, causes the\n`/internal/observability/assistant/alert_details_contextual_insights`\nendpoint to hang indefinitely.\n\n### Root cause\n`getLogRateAnalysisForAlert` and `getLogCategories` were pushed to the\ndata-fetcher queue unconditionally, regardless of whether any entity\ncontext was available. When all entity values are `undefined`,\n`getShouldMatchOrNotExistFilter` returns an empty array, so the\nresulting ES queries carry no entity-scoping filters and fan out across\n**all** configured log sources.\n\n### Fix\nAdded a `hasEntityFilters` flag (true when at least one of\n`serviceName`, `hostName`, `containerId`, `kubernetesPodName` is\ndefined) and wrapped both log data fetchers with `if\n(hasEntityFilters)`. When no entity context is present, running these\nanalyses has no meaningful scope and would scan all log data without\ncorrelation to the triggering alert.","sha":"384373226111f1aaf3369363ee97eedd803c3ac4"}}]}] BACKPORT--> Co-authored-by: Arturo Lidueña <arturo.liduena@elastic.co>
…en no entity filters are present (#290244) (#290485) # Backport This will backport the following commits from `main` to `9.4`: - [[Obs AI Assistant] Skip log rate analysis and log categories when no entity filters are present (#290244)](#290244) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Arturo Lidueña","email":"arturo.liduena@elastic.co"},"sourceCommit":{"committedDate":"2026-09-11T09:27:57Z","message":"[Obs AI Assistant] Skip log rate analysis and log categories when no entity filters are present (#290244)\n\nCloses Issue: https://github.com/elastic/sdh-kibana/issues/6510\n\n## Summary\n\nFixes a performance issue where clicking \"Help me understand this alert\"\non a `custom_threshold` alert that monitors a non-standard metric, one\nthat produces no `service.name`, `host.name`, `container.id`, or\n`kubernetes.pod.name` in the alert document, causes the\n`/internal/observability/assistant/alert_details_contextual_insights`\nendpoint to hang indefinitely.\n\n### Root cause\n`getLogRateAnalysisForAlert` and `getLogCategories` were pushed to the\ndata-fetcher queue unconditionally, regardless of whether any entity\ncontext was available. When all entity values are `undefined`,\n`getShouldMatchOrNotExistFilter` returns an empty array, so the\nresulting ES queries carry no entity-scoping filters and fan out across\n**all** configured log sources.\n\n### Fix\nAdded a `hasEntityFilters` flag (true when at least one of\n`serviceName`, `hostName`, `containerId`, `kubernetesPodName` is\ndefined) and wrapped both log data fetchers with `if\n(hasEntityFilters)`. When no entity context is present, running these\nanalyses has no meaningful scope and would scan all log data without\ncorrelation to the triggering alert.","sha":"384373226111f1aaf3369363ee97eedd803c3ac4","branchLabelMapping":{"^v9.6.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","backport:all-open","v9.6.0","Team:nightshift-context-and-research","Team:obs-signals-traces"],"title":"[Obs AI Assistant] Skip log rate analysis and log categories when no entity filters are present","number":290244,"url":"https://github.com/elastic/kibana/pull/290244","mergeCommit":{"message":"[Obs AI Assistant] Skip log rate analysis and log categories when no entity filters are present (#290244)\n\nCloses Issue: https://github.com/elastic/sdh-kibana/issues/6510\n\n## Summary\n\nFixes a performance issue where clicking \"Help me understand this alert\"\non a `custom_threshold` alert that monitors a non-standard metric, one\nthat produces no `service.name`, `host.name`, `container.id`, or\n`kubernetes.pod.name` in the alert document, causes the\n`/internal/observability/assistant/alert_details_contextual_insights`\nendpoint to hang indefinitely.\n\n### Root cause\n`getLogRateAnalysisForAlert` and `getLogCategories` were pushed to the\ndata-fetcher queue unconditionally, regardless of whether any entity\ncontext was available. When all entity values are `undefined`,\n`getShouldMatchOrNotExistFilter` returns an empty array, so the\nresulting ES queries carry no entity-scoping filters and fan out across\n**all** configured log sources.\n\n### Fix\nAdded a `hasEntityFilters` flag (true when at least one of\n`serviceName`, `hostName`, `containerId`, `kubernetesPodName` is\ndefined) and wrapped both log data fetchers with `if\n(hasEntityFilters)`. When no entity context is present, running these\nanalyses has no meaningful scope and would scan all log data without\ncorrelation to the triggering alert.","sha":"384373226111f1aaf3369363ee97eedd803c3ac4"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.6.0","branchLabelMappingKey":"^v9.6.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/290244","number":290244,"mergeCommit":{"message":"[Obs AI Assistant] Skip log rate analysis and log categories when no entity filters are present (#290244)\n\nCloses Issue: https://github.com/elastic/sdh-kibana/issues/6510\n\n## Summary\n\nFixes a performance issue where clicking \"Help me understand this alert\"\non a `custom_threshold` alert that monitors a non-standard metric, one\nthat produces no `service.name`, `host.name`, `container.id`, or\n`kubernetes.pod.name` in the alert document, causes the\n`/internal/observability/assistant/alert_details_contextual_insights`\nendpoint to hang indefinitely.\n\n### Root cause\n`getLogRateAnalysisForAlert` and `getLogCategories` were pushed to the\ndata-fetcher queue unconditionally, regardless of whether any entity\ncontext was available. When all entity values are `undefined`,\n`getShouldMatchOrNotExistFilter` returns an empty array, so the\nresulting ES queries carry no entity-scoping filters and fan out across\n**all** configured log sources.\n\n### Fix\nAdded a `hasEntityFilters` flag (true when at least one of\n`serviceName`, `hostName`, `containerId`, `kubernetesPodName` is\ndefined) and wrapped both log data fetchers with `if\n(hasEntityFilters)`. When no entity context is present, running these\nanalyses has no meaningful scope and would scan all log data without\ncorrelation to the triggering alert.","sha":"384373226111f1aaf3369363ee97eedd803c3ac4"}}]}] BACKPORT--> --------- Co-authored-by: Arturo Lidueña <arturo.liduena@elastic.co>
…hen no entity filters are present (#290244) (#290484) # Backport This will backport the following commits from `main` to `8.19`: - [[Obs AI Assistant] Skip log rate analysis and log categories when no entity filters are present (#290244)](#290244) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Arturo Lidueña","email":"arturo.liduena@elastic.co"},"sourceCommit":{"committedDate":"2026-09-11T09:27:57Z","message":"[Obs AI Assistant] Skip log rate analysis and log categories when no entity filters are present (#290244)\n\nCloses Issue: https://github.com/elastic/sdh-kibana/issues/6510\n\n## Summary\n\nFixes a performance issue where clicking \"Help me understand this alert\"\non a `custom_threshold` alert that monitors a non-standard metric, one\nthat produces no `service.name`, `host.name`, `container.id`, or\n`kubernetes.pod.name` in the alert document, causes the\n`/internal/observability/assistant/alert_details_contextual_insights`\nendpoint to hang indefinitely.\n\n### Root cause\n`getLogRateAnalysisForAlert` and `getLogCategories` were pushed to the\ndata-fetcher queue unconditionally, regardless of whether any entity\ncontext was available. When all entity values are `undefined`,\n`getShouldMatchOrNotExistFilter` returns an empty array, so the\nresulting ES queries carry no entity-scoping filters and fan out across\n**all** configured log sources.\n\n### Fix\nAdded a `hasEntityFilters` flag (true when at least one of\n`serviceName`, `hostName`, `containerId`, `kubernetesPodName` is\ndefined) and wrapped both log data fetchers with `if\n(hasEntityFilters)`. When no entity context is present, running these\nanalyses has no meaningful scope and would scan all log data without\ncorrelation to the triggering alert.","sha":"384373226111f1aaf3369363ee97eedd803c3ac4","branchLabelMapping":{"^v9.6.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","backport:all-open","v9.6.0","Team:nightshift-context-and-research","Team:obs-signals-traces"],"title":"[Obs AI Assistant] Skip log rate analysis and log categories when no entity filters are present","number":290244,"url":"https://github.com/elastic/kibana/pull/290244","mergeCommit":{"message":"[Obs AI Assistant] Skip log rate analysis and log categories when no entity filters are present (#290244)\n\nCloses Issue: https://github.com/elastic/sdh-kibana/issues/6510\n\n## Summary\n\nFixes a performance issue where clicking \"Help me understand this alert\"\non a `custom_threshold` alert that monitors a non-standard metric, one\nthat produces no `service.name`, `host.name`, `container.id`, or\n`kubernetes.pod.name` in the alert document, causes the\n`/internal/observability/assistant/alert_details_contextual_insights`\nendpoint to hang indefinitely.\n\n### Root cause\n`getLogRateAnalysisForAlert` and `getLogCategories` were pushed to the\ndata-fetcher queue unconditionally, regardless of whether any entity\ncontext was available. When all entity values are `undefined`,\n`getShouldMatchOrNotExistFilter` returns an empty array, so the\nresulting ES queries carry no entity-scoping filters and fan out across\n**all** configured log sources.\n\n### Fix\nAdded a `hasEntityFilters` flag (true when at least one of\n`serviceName`, `hostName`, `containerId`, `kubernetesPodName` is\ndefined) and wrapped both log data fetchers with `if\n(hasEntityFilters)`. When no entity context is present, running these\nanalyses has no meaningful scope and would scan all log data without\ncorrelation to the triggering alert.","sha":"384373226111f1aaf3369363ee97eedd803c3ac4"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.6.0","branchLabelMappingKey":"^v9.6.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/290244","number":290244,"mergeCommit":{"message":"[Obs AI Assistant] Skip log rate analysis and log categories when no entity filters are present (#290244)\n\nCloses Issue: https://github.com/elastic/sdh-kibana/issues/6510\n\n## Summary\n\nFixes a performance issue where clicking \"Help me understand this alert\"\non a `custom_threshold` alert that monitors a non-standard metric, one\nthat produces no `service.name`, `host.name`, `container.id`, or\n`kubernetes.pod.name` in the alert document, causes the\n`/internal/observability/assistant/alert_details_contextual_insights`\nendpoint to hang indefinitely.\n\n### Root cause\n`getLogRateAnalysisForAlert` and `getLogCategories` were pushed to the\ndata-fetcher queue unconditionally, regardless of whether any entity\ncontext was available. When all entity values are `undefined`,\n`getShouldMatchOrNotExistFilter` returns an empty array, so the\nresulting ES queries carry no entity-scoping filters and fan out across\n**all** configured log sources.\n\n### Fix\nAdded a `hasEntityFilters` flag (true when at least one of\n`serviceName`, `hostName`, `containerId`, `kubernetesPodName` is\ndefined) and wrapped both log data fetchers with `if\n(hasEntityFilters)`. When no entity context is present, running these\nanalyses has no meaningful scope and would scan all log data without\ncorrelation to the triggering alert.","sha":"384373226111f1aaf3369363ee97eedd803c3ac4"}}]}] BACKPORT--> --------- Co-authored-by: Arturo Lidueña <arturo.liduena@elastic.co>
Closes Issue: https://github.com/elastic/sdh-kibana/issues/6510
Summary
Fixes a performance issue where clicking "Help me understand this alert" on a
custom_thresholdalert that monitors a non-standard metric, one that produces noservice.name,host.name,container.id, orkubernetes.pod.namein the alert document, causes the/internal/observability/assistant/alert_details_contextual_insightsendpoint to hang indefinitely.Root cause
getLogRateAnalysisForAlertandgetLogCategorieswere pushed to the data-fetcher queue unconditionally, regardless of whether any entity context was available. When all entity values areundefined,getShouldMatchOrNotExistFilterreturns an empty array, so the resulting ES queries carry no entity-scoping filters and fan out across all configured log sources.Fix
Added a
hasEntityFiltersflag (true when at least one ofserviceName,hostName,containerId,kubernetesPodNameis defined) and wrapped both log data fetchers withif (hasEntityFilters). When no entity context is present, running these analyses has no meaningful scope and would scan all log data without correlation to the triggering alert.