-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow to return rules with matching active alerts
This change adds a `-rules-with-active-alerts` CLI argument to return rules with active alerts matching the enforced label. The use case is for an admin to write general-purpose alerting rules which individual users can still retrieve from the API. To avoid surprises ("why do I see this alert now?"), the feature needs to be explicitly enabled. Signed-off-by: Simon Pasquier <[email protected]>
- Loading branch information
1 parent
a177f41
commit 4ece18c
Showing
6 changed files
with
253 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
"status": "success", | ||
"data": { | ||
"groups": [ | ||
{ | ||
"name": "group3", | ||
"file": "testdata/rules3.yml", | ||
"rules": [ | ||
{ | ||
"state": "pending", | ||
"name": "Alert3", | ||
"query": "metric4{ns!=\"default\"} == 0", | ||
"duration": 300, | ||
"keepFiringFor": 0, | ||
"labels": {}, | ||
"annotations": {}, | ||
"alerts": [ | ||
{ | ||
"labels": { | ||
"alertname": "Alert3", | ||
"namespace": "ns3" | ||
}, | ||
"annotations": {}, | ||
"state": "pending", | ||
"activeAt": "2019-12-18T13:20:39.972915521+01:00", | ||
"value": "0e+00" | ||
} | ||
], | ||
"health": "ok", | ||
"evaluationTime": 0.000214, | ||
"lastEvaluation": "2024-04-29T14:23:52.903557247+02:00", | ||
"type": "alerting" | ||
}, | ||
{ | ||
"state": "firing", | ||
"name": "Alert4", | ||
"query": "metric5 == 0", | ||
"duration": 300, | ||
"keepFiringFor": 0, | ||
"labels": {}, | ||
"annotations": {}, | ||
"alerts": [ | ||
{ | ||
"labels": { | ||
"alertname": "Alert4", | ||
"namespace": "ns3", | ||
"state": "foo" | ||
}, | ||
"annotations": {}, | ||
"state": "pending", | ||
"activeAt": "2019-12-18T13:20:39.972915521+01:00", | ||
"value": "0e+00" | ||
}, | ||
{ | ||
"labels": { | ||
"alertname": "Alert1", | ||
"namespace": "ns3", | ||
"state": "bar" | ||
}, | ||
"annotations": {}, | ||
"state": "firing", | ||
"activeAt": "2019-12-18T13:14:39.972915521+01:00", | ||
"value": "0e+00" | ||
} | ||
], | ||
"health": "ok", | ||
"evaluationTime": 0.000214, | ||
"lastEvaluation": "2024-04-29T14:23:52.903557247+02:00", | ||
"type": "alerting" | ||
} | ||
], | ||
"interval": 10 | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters