From 3716326f3f19aae95789a078de9560b3cb432404 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 23 Nov 2023 18:37:42 +0000 Subject: [PATCH] rules: call NewScratchBuilder Need to initialize ScratchBuilder with a SymbolTable. Signed-off-by: Bryan Boreham --- rules/alerting.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rules/alerting.go b/rules/alerting.go index a99b2b4aa..7b0921a72 100644 --- a/rules/alerting.go +++ b/rules/alerting.go @@ -356,6 +356,8 @@ func (r *AlertingRule) Eval(ctx context.Context, ts time.Time, query QueryFunc, // or update the expression value for existing elements. resultFPs := map[uint64]struct{}{} + lb := labels.NewBuilder(labels.EmptyLabels()) + sb := labels.NewScratchBuilder(0) var vec promql.Vector alerts := make(map[uint64]*Alert, len(res)) for _, smpl := range res { @@ -391,14 +393,14 @@ func (r *AlertingRule) Eval(ctx context.Context, ts time.Time, query QueryFunc, return result } - lb := labels.NewBuilder(smpl.Metric).Del(labels.MetricName) - + lb.Reset(smpl.Metric) + lb.Del(labels.MetricName) r.labels.Range(func(l labels.Label) { lb.Set(l.Name, expand(l.Value)) }) lb.Set(labels.AlertName, r.Name()) - sb := labels.ScratchBuilder{} + sb.Reset() r.annotations.Range(func(a labels.Label) { sb.Add(a.Name, expand(a.Value)) })