Revert "ruler: correct logging of alert name & template data"

pull/16320/head
George Krajcsovits 3 months ago committed by GitHub
parent 503f3cb6d7
commit d085f7da9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      rules/manager.go
  2. 28
      template/template.go

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

@ -281,30 +281,14 @@ func NewTemplateExpander(
}
}
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{
res := struct {
Labels map[string]string
ExternalLabels map[string]string
ExternalURL string
Value interface{}
}{
Labels: labels,
ExternalLabels: externalLabels,
ExternalURL: externalURL,

Loading…
Cancel
Save