ruler: correct logging of alert name

The error messages we see in the embedded ruler in Mimir right now are contain `alert="unsupported value type"` and `data="unsupported value type"`

```
ts=2024-10-04T09:59:56.900015691Z caller=alerting.go:384 level=warn component=ruler insight=true user=XXX alert="unsupported value type" msg="Expanding alert template failed" err="error executing template __alert_service_mesh_down_alert: template: __alert_service_mesh_down_alert:1:139: executing \"__alert_service_mesh_down_alert\" at <.registry_name>: can't evaluate field registry_name in type struct { Labels map[string]string; ExternalLabels map[string]string; ExternalURL string; Value interface {} }" data="unsupported value type"
```

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
This commit is contained in:
Dimitar Dimitrov 2024-10-04 12:19:12 +02:00
parent 6c5e2f8fb9
commit b544127d9a
No known key found for this signature in database
GPG key ID: 4541B04E6C90EBC3
2 changed files with 2 additions and 2 deletions

View file

@ -381,7 +381,7 @@ func (r *AlertingRule) Eval(ctx context.Context, queryOffset time.Duration, ts t
result, err := tmpl.Expand()
if err != nil {
result = fmt.Sprintf("<error expanding template: %s>", err)
level.Warn(r.logger).Log("msg", "Expanding alert template failed", "err", err, "data", tmplData)
level.Warn(r.logger).Log("msg", "Expanding alert template failed", "err", err, "data", fmt.Sprintf("%#v", tmplData))
}
return result
}

View file

@ -323,7 +323,7 @@ func (m *Manager) LoadGroups(
externalLabels,
externalURL,
m.restored,
log.With(m.logger, "alert", r.Alert),
log.With(m.logger, "alert", r.Alert.Value),
))
continue
}