diff --git a/rules/manager.go b/rules/manager.go index 5cc8ca034..60c5b6604 100644 --- a/rules/manager.go +++ b/rules/manager.go @@ -306,7 +306,7 @@ func NewGroup(o GroupOptions) *Group { done: make(chan struct{}), managerDone: o.done, terminated: make(chan struct{}), - logger: log.With(o.Opts.Logger, "group", o.Name), + logger: log.With(o.Opts.Logger, "file", o.File, "group", o.Name), metrics: metrics, } } @@ -607,7 +607,7 @@ func (g *Group) Eval(ctx context.Context, ts time.Time) { // Canceled queries are intentional termination of queries. This normally // happens on shutdown and thus we skip logging of any errors here. if _, ok := err.(promql.ErrQueryCanceled); !ok { - level.Warn(g.logger).Log("msg", "Evaluating rule failed", "rule", rule, "err", err) + level.Warn(g.logger).Log("name", rule.Name(), "index", i, "msg", "Evaluating rule failed", "rule", rule, "err", err) } return } @@ -631,7 +631,7 @@ func (g *Group) Eval(ctx context.Context, ts time.Time) { rule.SetLastError(err) g.metrics.EvalFailures.WithLabelValues(GroupKey(g.File(), g.Name())).Inc() - level.Warn(g.logger).Log("msg", "Rule sample appending failed", "err", err) + level.Warn(g.logger).Log("name", rule.Name(), "index", i, "msg", "Rule sample appending failed", "err", err) return } g.seriesInPreviousEval[i] = seriesReturned @@ -645,12 +645,12 @@ func (g *Group) Eval(ctx context.Context, ts time.Time) { switch errors.Cause(err) { case storage.ErrOutOfOrderSample: numOutOfOrder++ - level.Debug(g.logger).Log("msg", "Rule evaluation result discarded", "err", err, "sample", s) + level.Debug(g.logger).Log("name", rule.Name(), "index", i, "msg", "Rule evaluation result discarded", "err", err, "sample", s) case storage.ErrDuplicateSampleForTimestamp: numDuplicates++ - level.Debug(g.logger).Log("msg", "Rule evaluation result discarded", "err", err, "sample", s) + level.Debug(g.logger).Log("name", rule.Name(), "index", i, "msg", "Rule evaluation result discarded", "err", err, "sample", s) default: - level.Warn(g.logger).Log("msg", "Rule evaluation result discarded", "err", err, "sample", s) + level.Warn(g.logger).Log("name", rule.Name(), "index", i, "msg", "Rule evaluation result discarded", "err", err, "sample", s) } } else { buf := [1024]byte{} @@ -658,10 +658,10 @@ func (g *Group) Eval(ctx context.Context, ts time.Time) { } } if numOutOfOrder > 0 { - level.Warn(g.logger).Log("msg", "Error on ingesting out-of-order result from rule evaluation", "numDropped", numOutOfOrder) + level.Warn(g.logger).Log("name", rule.Name(), "index", i, "msg", "Error on ingesting out-of-order result from rule evaluation", "numDropped", numOutOfOrder) } if numDuplicates > 0 { - level.Warn(g.logger).Log("msg", "Error on ingesting results from rule evaluation with different value but same timestamp", "numDropped", numDuplicates) + level.Warn(g.logger).Log("name", rule.Name(), "index", i, "msg", "Error on ingesting results from rule evaluation with different value but same timestamp", "numDropped", numDuplicates) } for metric, lset := range g.seriesInPreviousEval[i] { @@ -674,7 +674,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", lset.String(), "err", err) + level.Warn(g.logger).Log("name", rule.Name(), "index", i, "msg", "Adding stale sample failed", "sample", lset.String(), "err", err) } } }