Skip to content

[Obs AI Assistant] Skip log rate analysis and log categories when no entity filters are present - #290244

Merged
arturoliduena merged 3 commits into
elastic:mainfrom
arturoliduena:obs-ai-assistant-fix-alert-details-contextual-insights-no-entity-full-scan
Sep 11, 2026
Merged

[Obs AI Assistant] Skip log rate analysis and log categories when no entity filters are present#290244
arturoliduena merged 3 commits into
elastic:mainfrom
arturoliduena:obs-ai-assistant-fix-alert-details-contextual-insights-no-entity-full-scan

Conversation

@arturoliduena

@arturoliduena arturoliduena commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

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_threshold alert that monitors a non-standard metric, one that produces no service.name, host.name, container.id, or kubernetes.pod.name in the alert document, causes the /internal/observability/assistant/alert_details_contextual_insights endpoint to hang indefinitely.

Root cause

getLogRateAnalysisForAlert and getLogCategories were pushed to the data-fetcher queue unconditionally, regardless of whether any entity context was available. When all entity values are undefined, getShouldMatchOrNotExistFilter returns an empty array, so the resulting ES queries carry no entity-scoping filters and fan out across all configured log sources.

Fix

Added a hasEntityFilters flag (true when at least one of serviceName, hostName, containerId, kubernetesPodName is defined) and wrapped both log data fetchers with if (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.

@arturoliduena arturoliduena added bug Fixes for quality problems that affect the customer experience release_note:fix backport:all-open Backport to all branches that could still receive a release Team:nightshift-context-and-research Nightshift Context & Research Team labels Sep 10, 2026
@arturoliduena
arturoliduena marked this pull request as ready for review September 10, 2026 09:32
@arturoliduena
arturoliduena requested a review from a team as a code owner September 10, 2026 09:32
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

Pinging @elastic/nightshift-context-and-research-team (Team:nightshift-context-and-research)

@github-actions github-actions Bot left a comment

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.

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 jennypavlova left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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?

@arturoliduena

Copy link
Copy Markdown
Contributor Author

@jennypavlova, thanks for the review. I added the regression tests.

@arturoliduena
arturoliduena enabled auto-merge (squash) September 11, 2026 08:29

@jennypavlova jennypavlova left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Thanks for adding the tests :)

@kibanamachine

Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

History

@arturoliduena
arturoliduena merged commit 3843732 into elastic:main Sep 11, 2026
42 checks passed
@kibanamachine

Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.19, 9.4, 9.5

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

@kibanamachine

Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
8.19
9.4
9.5

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 Sep 11, 2026
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>
kibanamachine added a commit that referenced this pull request Sep 11, 2026
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>
kibanamachine added a commit that referenced this pull request Sep 11, 2026
…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>
kibanamachine added a commit that referenced this pull request Sep 13, 2026
…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>
kibanamachine added a commit that referenced this pull request Sep 13, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:all-open Backport to all branches that could still receive a release bug Fixes for quality problems that affect the customer experience release_note:fix Team:nightshift-context-and-research Nightshift Context & Research Team Team:obs-signals-traces v8.19.22 v9.4.7 v9.5.4 v9.6.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants