Alerting: Add limits to the Prometheus Rules API (#65169)
This commit adds a number of limits to the Grafana flavor of the Prometheus Rules API: 1. `limit` limits the maximum number of Rule Groups returned 2. `limit_rules` limits the maximum number of rules per Rule Group 3. `limit_alerts` limits the maximum number of alerts per rule It sorts Rule Groups and rules within Rule Groups such that data in the response is stable across requests. It also returns summaries (totals) for all Rule Groups, individual Rule Groups and rules.
This commit is contained in:
1 parent
093498a03b
commit
d96b0a71d3
8 files changed
+613
-23
No files matched your search
@@ -259,10 +259,16 @@ func TestIntegrationPrometheusRules(t *testing.T) {
|
||||
"lastEvaluation": "0001-01-01T00:00:00Z",
|
||||
"evaluationTime": 0
|
||||
}],
|
||||
"totals": {
|
||||
"inactive": 2
|
||||
},
|
||||
"interval": 60,
|
||||
"lastEvaluation": "0001-01-01T00:00:00Z",
|
||||
"evaluationTime": 0
|
||||
}]
|
||||
}],
|
||||
"totals": {
|
||||
"inactive": 2
|
||||
}
|
||||
}
|
||||
}`, string(b))
|
||||
}
|
||||
@@ -311,10 +317,16 @@ func TestIntegrationPrometheusRules(t *testing.T) {
|
||||
"lastEvaluation": "0001-01-01T00:00:00Z",
|
||||
"evaluationTime": 0
|
||||
}],
|
||||
"totals": {
|
||||
"inactive": 2
|
||||
},
|
||||
"interval": 60,
|
||||
"lastEvaluation": "0001-01-01T00:00:00Z",
|
||||
"evaluationTime": 0
|
||||
}]
|
||||
}],
|
||||
"totals": {
|
||||
"inactive": 2
|
||||
}
|
||||
}
|
||||
}`, string(b))
|
||||
return true
|
||||
@@ -454,10 +466,16 @@ func TestIntegrationPrometheusRulesFilterByDashboard(t *testing.T) {
|
||||
"lastEvaluation": "0001-01-01T00:00:00Z",
|
||||
"evaluationTime": 0
|
||||
}],
|
||||
"totals": {
|
||||
"inactive": 2
|
||||
},
|
||||
"interval": 60,
|
||||
"lastEvaluation": "0001-01-01T00:00:00Z",
|
||||
"evaluationTime": 0
|
||||
}]
|
||||
}],
|
||||
"totals": {
|
||||
"inactive": 2
|
||||
}
|
||||
}
|
||||
}`, dashboardUID)
|
||||
expectedFilteredByJSON := fmt.Sprintf(`
|
||||
@@ -481,10 +499,16 @@ func TestIntegrationPrometheusRulesFilterByDashboard(t *testing.T) {
|
||||
"lastEvaluation": "0001-01-01T00:00:00Z",
|
||||
"evaluationTime": 0
|
||||
}],
|
||||
"totals": {
|
||||
"inactive": 1
|
||||
},
|
||||
"interval": 60,
|
||||
"lastEvaluation": "0001-01-01T00:00:00Z",
|
||||
"evaluationTime": 0
|
||||
}]
|
||||
}],
|
||||
"totals": {
|
||||
"inactive": 1
|
||||
}
|
||||
}
|
||||
}`, dashboardUID)
|
||||
expectedNoneJSON := `
|
||||
|
||||
Reference in new issue
Block a user