mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
committed by
Carl Bergquist
parent
34f314552d
commit
e06abb30aa
@@ -93,7 +93,7 @@ func (am *AlertmanagerNotifier) createAlert(evalContext *alerting.EvalContext, m
|
||||
alertJSON.SetPath([]string{"annotations", "image"}, evalContext.ImagePublicURL)
|
||||
}
|
||||
|
||||
// Labels (from metrics tags + mandatory alertname).
|
||||
// Labels (from metrics tags + AlertRuleTags + mandatory alertname).
|
||||
tags := make(map[string]string)
|
||||
if match != nil {
|
||||
if len(match.Tags) == 0 {
|
||||
@@ -104,6 +104,9 @@ func (am *AlertmanagerNotifier) createAlert(evalContext *alerting.EvalContext, m
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, tag := range evalContext.Rule.AlertRuleTags {
|
||||
tags[tag.Key] = tag.Value
|
||||
}
|
||||
tags["alertname"] = evalContext.Rule.Name
|
||||
alertJSON.Set("labels", tags)
|
||||
return alertJSON
|
||||
|
||||
@@ -35,6 +35,7 @@ type Rule struct {
|
||||
State models.AlertStateType
|
||||
Conditions []Condition
|
||||
Notifications []string
|
||||
AlertRuleTags []*models.Tag
|
||||
|
||||
StateChanges int64
|
||||
}
|
||||
@@ -145,6 +146,7 @@ func NewRuleFromDBAlert(ruleDef *models.Alert) (*Rule, error) {
|
||||
model.Notifications = append(model.Notifications, uid)
|
||||
}
|
||||
}
|
||||
model.AlertRuleTags = ruleDef.GetTagsFromSettings()
|
||||
|
||||
for index, condition := range ruleDef.Settings.Get("conditions").MustArray() {
|
||||
conditionModel := simplejson.NewFromAny(condition)
|
||||
|
||||
Reference in New Issue
Block a user