Alerting: Add tags to alert rules (#10989)

Ref #6552
This commit is contained in:
Thibault Chataigner
2019-06-06 13:29:30 +02:00
committed by Carl Bergquist
parent 34f314552d
commit e06abb30aa
13 changed files with 201 additions and 70 deletions

View File

@@ -117,6 +117,21 @@ func (this *Alert) ContainsUpdates(other *Alert) bool {
return result
}
func (alert *Alert) GetTagsFromSettings() []*Tag {
tags := []*Tag{}
if alert.Settings != nil {
if data, ok := alert.Settings.CheckGet("alertRuleTags"); ok {
for tagNameString, tagValue := range data.MustMap() {
// MustMap() already guarantees the return of a `map[string]interface{}`.
// Therefore we only need to verify that tagValue is a String.
tagValueString := simplejson.NewFromAny(tagValue).MustString()
tags = append(tags, &Tag{Key: tagNameString, Value: tagValueString})
}
}
}
return tags
}
type AlertingClusterInfo struct {
ServerId string
ClusterSize int