mirror of
https://github.com/prometheus/prometheus.git
synced 2025-08-06 22:27:17 +02:00
Merge pull request #15093 from dimitarvdimitrov/dimitar/ruler/unsupported-logger
ruler: correct logging of alert name & template data
This commit is contained in:
commit
e19ff7a000
@ -342,7 +342,7 @@ func (m *Manager) LoadGroups(
|
||||
externalLabels,
|
||||
externalURL,
|
||||
!shouldRestore,
|
||||
m.logger.With("alert", r.Alert),
|
||||
m.logger.With("alert", r.Alert.Value),
|
||||
))
|
||||
continue
|
||||
}
|
||||
|
@ -281,14 +281,30 @@ func NewTemplateExpander(
|
||||
}
|
||||
}
|
||||
|
||||
// AlertTemplateData returns the interface to be used in expanding the template.
|
||||
func AlertTemplateData(labels, externalLabels map[string]string, externalURL string, smpl promql.Sample) interface{} {
|
||||
res := struct {
|
||||
type templateData struct {
|
||||
Labels map[string]string
|
||||
ExternalLabels map[string]string
|
||||
ExternalURL string
|
||||
Value interface{}
|
||||
}{
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer interface.
|
||||
func (t templateData) String() string {
|
||||
labelsString := func(labels map[string]string) string {
|
||||
// model.LabelSet has a ready String() method, that we can use.
|
||||
labelSet := make(model.LabelSet, len(t.Labels))
|
||||
for k, v := range t.Labels {
|
||||
labelSet[model.LabelName(k)] = model.LabelValue(v)
|
||||
}
|
||||
return labelSet.String()
|
||||
}
|
||||
|
||||
return fmt.Sprintf("<Labels: %s, ExternalLabels: %s, ExternalURL: %s, Value: %v>", labelsString(t.Labels), labelsString(t.ExternalLabels), t.ExternalURL, t.Value)
|
||||
}
|
||||
|
||||
// AlertTemplateData returns the interface to be used in expanding the template.
|
||||
func AlertTemplateData(labels, externalLabels map[string]string, externalURL string, smpl promql.Sample) interface{} {
|
||||
res := templateData{
|
||||
Labels: labels,
|
||||
ExternalLabels: externalLabels,
|
||||
ExternalURL: externalURL,
|
||||
|
Loading…
Reference in New Issue
Block a user