Alerting: Add rule_matcher filter to Prometheus rules API (#115297)
**What is this feature?** Add `rule_matcher` filter to the Prometheus-compatible list rules API: `/api/prometheus/grafana/api/v1/rules`. It allows to filter rules by static labels (not by alert instance labels). **Special notes:** - Equality (`=`) and inequality (`!=`) matchers are pushed down to the database. Regex matchers (`=~`, `!~`) are applied in-memory at the API layer. - SQLite: Uses GLOB pattern matching - MySQL / PostgreSQL: Use JSON functions to compare label values --------- Co-authored-by: Konrad Lalik <konradlalik@gmail.com>
This commit is contained in:
co-authored by
Konrad Lalik
parent
c7c1dd4ead
commit
c0295d06a3
@@ -462,4 +462,10 @@ type GetGrafanaRuleStatusesParams struct {
|
||||
// in: query
|
||||
// required: false
|
||||
Matchers []string `json:"matcher"`
|
||||
|
||||
// Filter rules by their static labels (not alert instance labels). Each value is a JSON-encoded Prometheus-like matcher (for example, {"type":0,"name":"severity","value":"critical"}).
|
||||
// For equality matchers with empty string values (e.g., name=""), rules that have the label with an empty value OR rules without the label will match (standard Prometheus behavior).
|
||||
// in: query
|
||||
// required: false
|
||||
RuleLabelMatchers []string `json:"rule_matcher"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user