Remove __name__ from alerts sent to AM.

Fixes #1861
pull/1865/head
Brian Brazil 8 years ago
parent f9533754d1
commit 6fc88d4b4d

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

@ -136,6 +136,12 @@ func TestAlertingRule(t *testing.T) {
t.Errorf("%d. Expected and actual outputs don't match:", i) 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")) 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)
}
}
} }
} }

Loading…
Cancel
Save