diff --git a/CHANGELOG.md b/CHANGELOG.md index 23d2c89da8..58293351ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## unreleased * [CHANGE] TSDB: Fix the predicate checking for blocks which are beyond the retention period to include the ones right at the retention boundary. #9633 +* [CHANGE] Rules: Execute 1 query instead of N (where N is the number of alerts within alert rule) when restoring alerts. #13980 * [ENHANCEMENT] Rules: Add `rule_group_last_restore_duration_seconds` to measure the time it takes to restore a rule group. #13974 ## 2.51.2 / 2024-04-09 diff --git a/rules/group.go b/rules/group.go index 4acce6e605..c4331a465b 100644 --- a/rules/group.go +++ b/rules/group.go @@ -681,15 +681,15 @@ func (g *Group) RestoreForState(ts time.Time) { continue } - result := map[string]storage.Series{} + seriesByLabels := map[string]storage.Series{} for sset.Next() { - result[sset.At().Labels().DropMetricName().String()] = sset.At() + seriesByLabels[sset.At().Labels().DropMetricName().String()] = sset.At() } alertRule.ForEachActiveAlert(func(a *Alert) { var s storage.Series - s, ok := result[a.Labels.String()] + s, ok := seriesByLabels[a.Labels.String()] if !ok { return }