Browse Source

Remove __name__ from alerts sent to AM.

Fixes #1861
pull/1865/head
Brian Brazil 8 years ago
parent
commit
6fc88d4b4d
  1. 3
      rules/alerting.go
  2. 6
      rules/manager_test.go

3
rules/alerting.go

@ -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,

6
rules/manager_test.go

@ -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)
}
}
}
}

Loading…
Cancel
Save