rules: call NewScratchBuilder

Need to initialize ScratchBuilder with a SymbolTable.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
Bryan Boreham 2023-11-23 18:37:42 +00:00
parent 925134e6de
commit 3716326f3f
1 changed files with 5 additions and 3 deletions

View File

@ -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))
})