Alerting: Add extended definition to prometheus alert rules api (#103320)

* Alerting: Add extended definition to prometheus alert rules api

This adds `isPaused` and `notificationSettings` to the paginated rules api to enable the paginated view of GMA rules.

refactor: make alert rule status and state retrieval extensible

This lets us get status from other sources than the local ruler.

* update swagger spec

* add safety checks in test
This commit is contained in:
Moustafa Baiou
2025-04-23 16:14:09 -04:00
committed by GitHub
parent b09d79b21c
commit 9f07e49cdd
9 changed files with 293 additions and 116 deletions

View File

@ -260,6 +260,7 @@ func TestIntegrationPrometheusRules(t *testing.T) {
"label1": "val1"
},
"health": "ok",
"isPaused": false,
"type": "alerting",
"lastEvaluation": "0001-01-01T00:00:00Z",
"evaluationTime": 0
@ -270,6 +271,7 @@ func TestIntegrationPrometheusRules(t *testing.T) {
"folderUid": "default",
"uid": "%s",
"health": "ok",
"isPaused": false,
"type": "alerting",
"lastEvaluation": "0001-01-01T00:00:00Z",
"evaluationTime": 0
@ -323,6 +325,7 @@ func TestIntegrationPrometheusRules(t *testing.T) {
"label1": "val1"
},
"health": "ok",
"isPaused": false,
"type": "alerting",
"lastEvaluation": "0001-01-01T00:00:00Z",
"evaluationTime": 0
@ -333,6 +336,7 @@ func TestIntegrationPrometheusRules(t *testing.T) {
"folderUid": "default",
"uid": "%s",
"health": "ok",
"isPaused": false,
"type": "alerting",
"lastEvaluation": "0001-01-01T00:00:00Z",
"evaluationTime": 0
@ -483,6 +487,7 @@ func TestIntegrationPrometheusRulesFilterByDashboard(t *testing.T) {
"__panelId__": "1"
},
"health": "ok",
"isPaused": false,
"type": "alerting",
"lastEvaluation": "0001-01-01T00:00:00Z",
"evaluationTime": 0
@ -493,6 +498,7 @@ func TestIntegrationPrometheusRulesFilterByDashboard(t *testing.T) {
"folderUid": "default",
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
"health": "ok",
"isPaused": false,
"type": "alerting",
"lastEvaluation": "0001-01-01T00:00:00Z",
"evaluationTime": 0
@ -530,6 +536,7 @@ func TestIntegrationPrometheusRulesFilterByDashboard(t *testing.T) {
"__panelId__": "1"
},
"health": "ok",
"isPaused": false,
"type": "alerting",
"lastEvaluation": "0001-01-01T00:00:00Z",
"evaluationTime": 0