Alertmanager notifier: add "metric" labels if no tags

Signed-off-by: Thibault Chataigner <t.chataigner@criteo.com>
This commit is contained in:
Thibault Chataigner 2017-12-13 13:37:49 +01:00 committed by bergquist
parent 3a7939c930
commit a8264fe316

View File

@ -72,8 +72,12 @@ func (this *AlertmanagerNotifier) Notify(evalContext *alerting.EvalContext) erro
}
tags := make(map[string]string)
for k, v := range match.Tags {
tags[k] = v
if len(match.Tags) == 0 {
tags["metric"] = match.Metric
} else {
for k, v := range match.Tags {
tags[k] = v
}
}
tags["alertname"] = evalContext.Rule.Name
alertJSON.Set("labels", tags)