fix(notifier): create a new alert when relabeling alters labels

Signed-off-by: machine424 <ayoubmrini424@gmail.com>
This commit is contained in:
machine424 2025-08-25 16:32:34 +02:00
parent bd725fd6b8
commit 8f79470ca9
No known key found for this signature in database
GPG Key ID: A4B001A4FDEE017D

View File

@ -84,7 +84,18 @@ func relabelAlerts(relabelConfigs []*relabel.Config, externalLabels labels.Label
if !keep { if !keep {
continue continue
} }
a.Labels = lb.Labels()
// If relabeling has altered the labels, create a new Alert to preserve immutability.
if !labels.Equal(a.Labels, lb.Labels()) {
a = &Alert{
Labels: lb.Labels(),
Annotations: a.Annotations,
StartsAt: a.StartsAt,
EndsAt: a.EndsAt,
GeneratorURL: a.GeneratorURL,
}
}
relabeledAlerts = append(relabeledAlerts, a) relabeledAlerts = append(relabeledAlerts, a)
} }
return relabeledAlerts return relabeledAlerts