-
Notifications
You must be signed in to change notification settings - Fork 67
CNV-80440: management: add single alert rule endpoints #1121
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
base: main-alerts-management-api
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,3 +39,57 @@ OpenShift supports routing user workload alerts to: | |
| This is a cluster configuration choice and does not change the plugin API shape. The plugin reads alerts from Alertmanager (for firing/silenced) and Prometheus (for pending), then merges platform and user workload results when available. | ||
|
|
||
| The plugin intentionally reads from only the in-cluster Alertmanager endpoints. Supporting multiple external Alertmanagers would introduce ambiguous alert state and silencing outcomes because each instance can apply different routing, inhibition, and silence configurations. | ||
|
|
||
| ### Managing alert rules via the Management API | ||
|
|
||
| | Operation | Single | Bulk | | ||
| |---|---|---| | ||
| | Create | `POST /api/v1/alerting/rules` | n/a | | ||
| | Update (labels, drop/restore, classification) | `PATCH /api/v1/alerting/rules/{ruleId}` | `PATCH /api/v1/alerting/rules` | | ||
| | Delete | `DELETE /api/v1/alerting/rules/{ruleId}` | `DELETE /api/v1/alerting/rules` | | ||
|
|
||
| **Single update** (`PATCH /rules/{ruleId}`): | ||
| - Request body uses `UpdateAlertRuleRequest` (labels and/or classification, or | ||
| `alertingRuleEnabled` alone for drop/restore). | ||
| - Success: HTTP `200` with `UpdateAlertRuleResult` (`statusCode: 204`). The | ||
| returned `id` may differ from the path `ruleId` when labels change the stable ID. | ||
| - Failure: standard `ErrorResponse` with the corresponding HTTP status | ||
| (400/401/403/404/405/409/413/500). Errors include a message so callers can act on them. | ||
| - Non-atomic combined updates: when both `classification` and `labels` are set, | ||
| classification is applied first, then labels. If the label step fails, the | ||
| classification change may already be persisted and the request still returns | ||
| an error. Retry or inspect cluster state before re-applying classification. | ||
|
|
||
| **Bulk update** (`PATCH /rules`): | ||
| - Request body includes `ruleIds` (1–100) plus the same mutation fields. | ||
| - Always returns HTTP `200` with per-rule `statusCode`/`message` entries so | ||
| partial success is visible. | ||
| - Same non-atomic classification-then-labels behavior as single update; a failed | ||
| label step is reported on that rule's result while classification may remain. | ||
|
|
||
| **Single delete** (`DELETE /rules/{ruleId}`): | ||
| - Success: HTTP `204`. | ||
| - Failure: `ErrorResponse` with HTTP status (400/401/403/404/405/409/500). | ||
|
|
||
| **Bulk delete** (`DELETE /rules`): | ||
| - Request body includes `ruleIds`. | ||
| - Always returns HTTP `200` with per-rule results. | ||
|
|
||
|
Comment on lines
+51
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
echo '--- alerting rules paths and responses ---'
rg -n -A40 '/alerting/rules' api/openapi.yaml | head -300
echo '--- ruleIds constraints ---'
rg -n -B3 -A12 'ruleIds' api/openapi.yamlRepository: openshift/monitoring-plugin Length of output: 1270 🏁 Script executed: #!/bin/bash
set -eu
echo '--- OpenAPI paths containing alert rules ---'
rg -n -i -B3 -A35 'rules' api/openapi.yaml | head -500
echo '--- response definitions and status references ---'
rg -n -i -B3 -A12 'responses:|statusCode|ErrorResponse' api/openapi.yaml | head -500Repository: openshift/monitoring-plugin Length of output: 28662 Document the bulk delete The single-update and single-delete status lists match 🤖 Prompt for AI Agents |
||
| ### Managing user-defined alert rules | ||
|
|
||
| | Rule ownership | Editable? | Classification? | Drop/Restore? | | ||
| |---|---|---|---| | ||
| | User-owned | Yes (direct PR mutation) | Yes (set labels directly) | No (ARC not supported) | | ||
| | Operator-managed | No (reconciled) | No | No | | ||
| | GitOps-managed | No (reconciled) | No | No | | ||
|
|
||
| **User-owned** rules can be fully edited (labels, severity, expr, annotations) | ||
| via the update API, which mutates the PrometheusRule directly. | ||
|
|
||
| **Operator-managed** and **GitOps-managed** user-defined rules cannot be edited | ||
| because the owning controller would reconcile the change. These alerts can only | ||
| be **silenced** via Alertmanager silences. | ||
|
|
||
| ARC-based operations (classification overrides, drop/restore) are not available | ||
| for any user-defined rule because the user workload stack does not process | ||
| AlertRelabelConfigs. If this capability is needed, open an RFE against CMO. | ||
Uh oh!
There was an error while loading. Please reload this page.