Remove __name__ from alerts sent to AM.

Fixes #1861
This commit is contained in:
Brian Brazil 2016-08-01 23:32:01 +01:00
parent f9533754d1
commit 6fc88d4b4d
2 changed files with 7 additions and 2 deletions

View file

@ -198,6 +198,7 @@ func (r *AlertingRule) eval(ts model.Time, engine *promql.Engine, externalURLPat
return model.LabelValue(result)
}
delete(smpl.Metric, model.MetricNameLabel)
labels := make(model.LabelSet, len(smpl.Metric)+len(r.labels)+1)
for ln, lv := range smpl.Metric {
labels[ln] = lv
@ -219,8 +220,6 @@ func (r *AlertingRule) eval(ts model.Time, engine *promql.Engine, externalURLPat
continue
}
delete(smpl.Metric, model.MetricNameLabel)
r.active[fp] = &Alert{
Labels: labels,
Annotations: annotations,

View file

@ -136,6 +136,12 @@ func TestAlertingRule(t *testing.T) {
t.Errorf("%d. Expected and actual outputs don't match:", i)
t.Fatalf("Expected:\n%v\n----\nActual:\n%v", strings.Join(expected, "\n"), strings.Join(actual, "\n"))
}
for _, aa := range rule.ActiveAlerts() {
if _, ok := aa.Labels[model.MetricNameLabel]; ok {
t.Fatalf("%s label set on active alert: %s", model.MetricNameLabel, aa.Labels)
}
}
}
}