Alerting: Improve logs in state manager and historian (#57374)

* Touch up log statements, fix casing, add and normalize contexts

* Dedicated logger for dashboard resolver

* Avoid injecting logger to historian

* More minor log touch-ups

* Dedicated logger for state manager

* Use rule context in annotation creator

* Rename base logger and avoid redundant contextual loggers
This commit is contained in:
Alexander Weaver
2022-10-21 16:16:51 -05:00
committed by GitHub
parent 910154c102
commit de46c1b002
10 changed files with 54 additions and 59 deletions

View File

@@ -90,13 +90,13 @@ func (rs *ruleStates) getOrCreate(ctx context.Context, log log.Logger, alertRule
}
}
if len(dupes) > 0 {
log.Warn("evaluation result contains either reserved labels or labels declared in the rules. Those labels from the result will be ignored", "labels", dupes)
log.Warn("Evaluation result contains either reserved labels or labels declared in the rules. Those labels from the result will be ignored", "labels", dupes)
}
il := ngModels.InstanceLabels(lbs)
id, err := il.StringKey()
if err != nil {
log.Error("error getting cacheId for entry", "error", err.Error())
log.Error("Error getting cacheId for entry", "error", err)
}
if state, ok := rs.states[id]; ok {
@@ -145,7 +145,7 @@ func (rs *ruleStates) expandRuleLabelsAndAnnotations(ctx context.Context, log lo
ev, err := expandTemplate(ctx, alertRule.Title, v, templateLabels, alertInstance, externalURL)
expanded[k] = ev
if err != nil {
log.Error("error in expanding template", "name", k, "value", v, "error", err.Error())
log.Error("Error in expanding template", "name", k, "value", v, "error", err)
// Store the original template on error.
expanded[k] = v
}