From 26d8ae0e4111722c7380acaab29b619baca5533a Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 8 Nov 2021 16:52:33 +0000 Subject: [PATCH] Rules: simplify map key for stale series detection The rules manager keeps a note of which series were generated by the last run, so it can write a stale marker to those that disappeared. Since the keys are not for human eyes, we can use a simpler format and save the effort of quoting label values. Signed-off-by: Bryan Boreham --- rules/manager.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rules/manager.go b/rules/manager.go index 2ab7eb62d..1e50e1035 100644 --- a/rules/manager.go +++ b/rules/manager.go @@ -652,7 +652,8 @@ func (g *Group) Eval(ctx context.Context, ts time.Time) { level.Warn(g.logger).Log("msg", "Rule evaluation result discarded", "err", err, "sample", s) } } else { - seriesReturned[s.Metric.String()] = s.Metric + buf := [1024]byte{} + seriesReturned[string(s.Metric.Bytes(buf[:]))] = s.Metric } } if numOutOfOrder > 0 { @@ -672,7 +673,7 @@ func (g *Group) Eval(ctx context.Context, ts time.Time) { // Do not count these in logging, as this is expected if series // is exposed from a different rule. default: - level.Warn(g.logger).Log("msg", "Adding stale sample failed", "sample", metric, "err", err) + level.Warn(g.logger).Log("msg", "Adding stale sample failed", "sample", lset.String(), "err", err) } } }