Skip to content

[Alerting V2] Agent Builder: get_rule_events tool for episode attachments - #288638

Merged
ana-davydova merged 11 commits into
elastic:mainfrom
ana-davydova:alertingv2-agentbuilder-712
Sep 15, 2026
Merged

ana-davydova merged 11 commits into
elastic:mainfrom
ana-davydova:alertingv2-agentbuilder-712

Conversation

@ana-davydova

@ana-davydova ana-davydova commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an attachment-scoped get_rule_events tool so Agent Builder can fetch .rule-events rows for an attached platform alert episode (breaches, recoveries, timing) without stuffing the full timeline into the snapshot.

Fetch path: get_rule_eventsEpisodesClient.getEvents → shared buildEpisodeEventsQuery (same query as the episode details timeline).

  • Tool id: platform.alerting.get_rule_events.{attachmentId}
  • Episode id is closed over from the attachment (not a free-form argument)
  • Privilege: Alerts: Read
  • Call with no arguments to fetch this episode’s events; optional start/end (together) to narrow @timestamp, optional status for lifecycle (inactive | pending | active | recovering)
  • Result: { events, count, truncated }data is kept and parsed to an object; at most 100 rows (LIMIT 101, return 100); truncated is true only when more than 100 rows exist
  • Projected fields: @timestamp, episode.id, episode.status, rule.id, group_hash, severity, source, data (source added to the shared KEEP; no evaluation status / type)

Closes elastic/rna-program#938 (parent elastic/rna-program#712).

Test plan

  • Jest: episode_events_query, episodes_client, get_rule_events, episode_attachment_type
  • Open a platform alert episode, open Agent Builder, confirm get_rule_events is listed next to refresh_episode and get_rule
  • Call the tool with {} and confirm events for that episode (oldest first), with object data and truncated: false when under 100 rows
  • Pass start/end together and confirm the window is applied; passing only one returns an error
  • Pass status: "active" (not episode.status) and confirm the lifecycle filter is applied
  • Confirm Alerts: Read is required; unauthorized users get the privilege error result
  • Confirm a missing episode returns not-found; get() failures log AGENT_BUILDER_EPISODE_LOOKUP_FAILED separately from GET_RULE_EVENTS_FAILED
image image image

@ana-davydova
ana-davydova requested a review from a team as a code owner September 2, 2026 12:45
@github-actions github-actions Bot added the author:actionable-obs PRs authored by the actionable obs team label Sep 2, 2026
@kibanamachine

Copy link
Copy Markdown
Contributor

PR size reminder

This PR has 820 added lines of reviewable code, which is above the 500-line guideline for Nightshift PRs.

Large PRs get significantly less review engagement and take longer to merge. Consider splitting this into smaller, focused PRs before requesting review.

@elastic-vault-github-plugin-prod
elastic-vault-github-plugin-prod Bot requested a review from a team as a code owner September 2, 2026 12:58
@ana-davydova
ana-davydova marked this pull request as draft September 2, 2026 13:00
@ana-davydova ana-davydova added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting closes:rna PR closes an issue on the RNA Program Board labels Sep 2, 2026
@ana-davydova
ana-davydova marked this pull request as ready for review September 2, 2026 14:26

@dmlemeshko dmlemeshko 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.

src/platform/test/tsconfig.json changes lgtm

@kibanamachine

kibanamachine commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

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
alertingVTwo 861.1KB 861.5KB +464.0B
Unknown metric groups

total optimizer output size

id before after diff
all 63.9MB 63.9MB +464.0B

History

@miguelmartin-elastic miguelmartin-elastic 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.

LGTM! Thanks for addressing the comments

@ana-davydova
ana-davydova merged commit dd9e651 into elastic:main Sep 15, 2026
41 checks passed
@ana-davydova
ana-davydova deleted the alertingv2-agentbuilder-712 branch September 15, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author:actionable-obs PRs authored by the actionable obs team backport:skip This PR does not require backporting closes:rna PR closes an issue on the RNA Program Board release_note:skip Skip the PR/issue when compiling release notes v9.6.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants