mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-02-19 15:30:17 +00:00
vmalert: skip automatically added labels on alerts restore (#871)
Label `alertgroup` was introduced in #611 and automatically added to generated time series. By mistake, this new label wasn't correctly purged on restore event and affected alert's ID uniqueness. This commit removes `alertgroup` label in restore function. https://github.com/VictoriaMetrics/VictoriaMetrics/issues/870
This commit is contained in:
parent
e8fe618bbb
commit
333675875f
2 changed files with 7 additions and 3 deletions
app/vmalert
|
@ -422,6 +422,9 @@ func (ar *AlertingRule) Restore(ctx context.Context, q datasource.Querier, lookb
|
||||||
if l.Name == alertNameLabel {
|
if l.Name == alertNameLabel {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if l.Name == alertGroupNameLabel {
|
||||||
|
continue
|
||||||
|
}
|
||||||
// drop all overridden labels
|
// drop all overridden labels
|
||||||
if _, ok := ar.Labels[l.Name]; ok {
|
if _, ok := ar.Labels[l.Name]; ok {
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -355,6 +355,7 @@ func TestAlertingRule_Restore(t *testing.T) {
|
||||||
metricWithValueAndLabels(t, float64(time.Now().Truncate(time.Hour).Unix()),
|
metricWithValueAndLabels(t, float64(time.Now().Truncate(time.Hour).Unix()),
|
||||||
"__name__", alertForStateMetricName,
|
"__name__", alertForStateMetricName,
|
||||||
alertNameLabel, "",
|
alertNameLabel, "",
|
||||||
|
alertGroupNameLabel, "groupID",
|
||||||
"foo", "bar",
|
"foo", "bar",
|
||||||
"namespace", "baz",
|
"namespace", "baz",
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue