prometheus/rules
Julien Pivotto e5c77afc71 rules: skip template labels when querying ALERTS_FOR_STATE for restore
QueryForStateSeries built Select matchers from the raw rule labels,
which can contain Go template expressions such as
`instance_{{ $labels.instance }}`. The stored ALERTS_FOR_STATE series
carry the per-instance evaluated values (e.g. `instance_0`), so the
unevaluated template string never matched, leaving seriesByLabels empty
and silently skipping restoration for every active alert.

Fix by omitting any label whose value contains `{{` from the matcher
list. Static labels (including `__name__` and `alertname`) are never
templated and continue to scope the query to the correct rule. The
in-memory lookup against evaluated alert labels that follows is
unaffected, so the single-query-per-rule optimisation introduced in
#13980 is fully preserved.

Fixes #16883
Ref #13980
Ref #18364

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-03-26 15:06:01 +01:00
..
fixtures Optimise concurrent rule evaluation for rules querying ALERTS and ALERTS_FOR_STATE (#17064) 2025-08-21 16:57:57 +02:00
alerting.go rules: skip template labels when querying ALERTS_FOR_STATE for restore 2026-03-26 15:06:01 +01:00
alerting_test.go rules: skip template labels when querying ALERTS_FOR_STATE for restore 2026-03-26 15:06:01 +01:00
group.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
group_test.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
manager.go Refactor parse.go into an instance-based Parser interface 2026-02-11 11:21:49 +01:00
manager_test.go chore(lint): enable wg.Go 2026-02-17 15:21:51 +01:00
origin.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
origin_test.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
recording.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
recording_test.go Refactor parse.go into an instance-based Parser interface 2026-02-11 11:21:49 +01:00
rule.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00