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 <bjboreham@gmail.com>
This commit is contained in:
Bryan Boreham 2021-11-08 16:52:33 +00:00 committed by Julien Pivotto
parent 628211c25a
commit 26d8ae0e41

View file

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