Notifier: don't reuse payload after relabeling

Also clarify why these variables are being cleared.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
pull/13735/head
Bryan Boreham 9 months ago
parent 9acae57937
commit 57c799132b

@ -481,14 +481,11 @@ func (n *Manager) sendAll(alerts ...*Alert) bool {
if len(ams.cfg.AlertRelabelConfigs) > 0 { if len(ams.cfg.AlertRelabelConfigs) > 0 {
amAlerts = relabelAlerts(ams.cfg.AlertRelabelConfigs, labels.Labels{}, alerts) amAlerts = relabelAlerts(ams.cfg.AlertRelabelConfigs, labels.Labels{}, alerts)
// TODO(nabokihms): figure out the right way to cache marshalled alerts.
// Now it works well only for happy cases.
v1Payload = nil
v2Payload = nil
if len(amAlerts) == 0 { if len(amAlerts) == 0 {
continue continue
} }
// We can't use the cached values from previous iteration.
v1Payload, v2Payload = nil, nil
} }
switch ams.cfg.APIVersion { switch ams.cfg.APIVersion {
@ -531,6 +528,11 @@ func (n *Manager) sendAll(alerts ...*Alert) bool {
} }
} }
if len(ams.cfg.AlertRelabelConfigs) > 0 {
// We can't use the cached values on the next iteration.
v1Payload, v2Payload = nil, nil
}
for _, am := range ams.ams { for _, am := range ams.ams {
wg.Add(1) wg.Add(1)

Loading…
Cancel
Save