Skip to content

OLS-1188: Add the ability to attach Alert Rules and Silences to the prompt#1941

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
kyoto:attach-alert-rule-silence
May 19, 2026
Merged

OLS-1188: Add the ability to attach Alert Rules and Silences to the prompt#1941
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
kyoto:attach-alert-rule-silence

Conversation

@kyoto
Copy link
Copy Markdown
Member

@kyoto kyoto commented May 14, 2026

Summary by CodeRabbit

  • New Features
    • Attach Alertmanager Silence and Alerting Rule YAML to conversations; new menu options and automatic context recognition on their detail pages
  • Documentation
    • Updated attachments specification to include the new types and keying/persistence behavior
  • Localization
    • Added UI text for Alerting Rule and Silence handling
  • Tests
    • Added validation tests for rule IDs and silence ID format

@kyoto kyoto added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 14, 2026
@openshift-ci openshift-ci Bot requested review from joshuawilson and syedriko May 14, 2026 07:15
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 14, 2026

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

1 similar comment
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 14, 2026

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 64ca82db-8fce-474f-a00d-5a47b40f8c94

📥 Commits

Reviewing files that changed from the base of the PR and between 558b765 and 7bd419e.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • .ai/spec/what/attachments.md
  • locales/en/plugin__lightspeed-console-plugin.json
  • package.json
  • src/components/Prompt.tsx
  • src/hooks/useLocationContext.ts
  • src/validation.ts
  • unit-tests/validation.test.ts
✅ Files skipped from review due to trivial changes (1)
  • package.json
🚧 Files skipped from review as they are similar to previous changes (5)
  • locales/en/plugin__lightspeed-console-plugin.json
  • .ai/spec/what/attachments.md
  • src/validation.ts
  • src/components/Prompt.tsx
  • src/hooks/useLocationContext.ts

📝 Walkthrough

Walkthrough

The PR extends the plugin to support two new monitoring resource attachments: Alertmanager Silence (detected via /monitoring/silences/{uuid}) and Alerting Rule (detected via /monitoring/alertrules/{hash}). It adds URL pattern detection, YAML fetching from APIs, validation helpers, UI strings, and tests for the new validators and rule-hash function.

Changes

Silence and Alerting Rule Attachment Support

Layer / File(s) Summary
Validation foundation and rule ID hashing
src/validation.ts, unit-tests/validation.test.ts
Exports alertingRuleID that builds a comma-delimited key from group/rule fields plus serialized labels and hashes it with murmur3 using monitoring-salt. Adds isValidSilenceID to validate lowercase-hex UUID-like silence IDs. Tests cover deterministic hashing, label inclusion, undefined duration handling, and silence ID acceptance/rejection.
URL context detection
src/hooks/useLocationContext.ts
Detects Silence and AlertingRule resources in monitoring URLs (/monitoring/silences/<id> and /monitoring/alertrules/<hash>), validates IDs, and sets location context (kind, name) while clearing namespace for these non-Kubernetes resources.
Attachment fetching and UI integration
src/components/Prompt.tsx, locales/en/plugin__lightspeed-console-plugin.json
Adds SILENCE_ENDPOINT, treats Alert, AlertingRule, and Silence as non-K8s kinds disabling K8s watch, extends onAttachMenuSelect to fetch Silence YAML from Alertmanager and find AlertingRule by alertingRuleID from Prometheus rules API, adds menu items and localization strings, and handles errors/loading states.
Specification and metadata updates
.ai/spec/what/attachments.md, package.json
Documents the new Silence and AlertingRule attachment types and composite keying rules; adjusts attachment numbering and reorders dependencies in package.json.

Sequence Diagram

sequenceDiagram
    participant User
    participant Browser as Prompt Component
    participant Router as URL Router
    participant Context as useLocationContext
    participant AlertMgr as Alertmanager API
    participant Prometheus as Prometheus API

    User->>Router: Navigate to /monitoring/silences/{uuid}
    Router->>Context: URL change detected
    Context->>Context: Parse URL, validate silence UUID
    Context->>Browser: Update context state (kind='Silence', name=uuid)
    
    User->>Browser: Click "Attach" → Select "Silence"
    Browser->>AlertMgr: Fetch silence details GET /api/v2/silences/{uuid}
    AlertMgr-->>Browser: Silence JSON response
    Browser->>Browser: Convert to YAML
    Browser->>Browser: Attach to message

    User->>Router: Navigate to /monitoring/alertrules/{hash}
    Router->>Context: URL change detected
    Context->>Context: Parse URL, set alerting rule context
    Context->>Browser: Update context state (kind='AlertingRule', name=hash)
    
    User->>Browser: Click "Attach" → Select "Alerting Rule"
    Browser->>Prometheus: Fetch alerting rules GET /api/v1/rules
    Prometheus-->>Browser: Rules list response
    Browser->>Browser: Find rule matching hash (via alertingRuleID)
    Browser->>Browser: Convert rule to YAML
    Browser->>Browser: Attach to message
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Two new monitors hop into your chat!
Silences and rules, no more silence on that—
Hash-matched with care, validated with pride,
YAML fetched and attached, right by your side.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately summarizes the main change: adding functionality to attach Alert Rules and Silences to the prompt, which is confirmed by all modified files supporting this feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

@kyoto kyoto force-pushed the attach-alert-rule-silence branch from 558b765 to 7bd419e Compare May 15, 2026 05:58
@kyoto
Copy link
Copy Markdown
Member Author

kyoto commented May 15, 2026

Rebased

@zhuje
Copy link
Copy Markdown

zhuje commented May 18, 2026

/retest

@zhuje
Copy link
Copy Markdown

zhuje commented May 18, 2026

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label May 18, 2026
@kyoto
Copy link
Copy Markdown
Member Author

kyoto commented May 19, 2026

Override test failure unrelated to this change:
/override "Red Hat Konflux / e2e-console-pf6 / lightspeed-console"

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 19, 2026

@kyoto: Overrode contexts on behalf of kyoto: Red Hat Konflux / e2e-console-pf6 / lightspeed-console

Details

In response to this:

Override test failure unrelated to this change:
/override "Red Hat Konflux / e2e-console-pf6 / lightspeed-console"

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-merge-bot openshift-merge-bot Bot merged commit 1571a6a into openshift:main May 19, 2026
5 of 6 checks passed
@kyoto kyoto deleted the attach-alert-rule-silence branch May 19, 2026 00:45
@kyoto kyoto changed the title Add the ability to attach Alert Rules and Silences to the prompt OLS-1188: Add the ability to attach Alert Rules and Silences to the prompt May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants