From 5a21f69f069aaa547ee949e46b71545b10c5b2d9 Mon Sep 17 00:00:00 2001 From: Alan Hollis Date: Wed, 5 Jan 2022 09:42:37 +0000 Subject: [PATCH] Add timestamp as label for alertmanager Without the timestamp there is not enough entropy in the hash for alertmanager to recongise that this is a new alert for some cases. Adding the timestamp ensures that a new hash for the alert is created each time and therefore no updates get missed. Signed-off-by: Alan Hollis --- docs/spec/v1beta1/provider.md | 1 + internal/notifier/alertmanager.go | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/spec/v1beta1/provider.md b/docs/spec/v1beta1/provider.md index b0745d4ae..4541678ef 100644 --- a/docs/spec/v1beta1/provider.md +++ b/docs/spec/v1beta1/provider.md @@ -333,6 +333,7 @@ The provider will send the following labels for the event. | ----------- | -------------------------------------------------------------------------------------------------- | | alertname | The string Flux followed by the Kind and the reason for the event e.g FluxKustomizationProgressing | | severity | The severity of the event (error|info) | +| timestamp | The timestamp of the event | | reason | The machine readable reason for the objects transition into the current status | | kind | The kind of the involved object associated with the event | | name | The name of the involved object associated with the event | diff --git a/internal/notifier/alertmanager.go b/internal/notifier/alertmanager.go index 0051b3184..efee975ff 100644 --- a/internal/notifier/alertmanager.go +++ b/internal/notifier/alertmanager.go @@ -72,6 +72,7 @@ func (s *Alertmanager) Post(event events.Event) error { labels["alertname"] = "Flux" + event.InvolvedObject.Kind + strings.Title(event.Reason) labels["severity"] = event.Severity labels["reason"] = event.Reason + labels["timestamp"] = event.Timestamp.String() labels["kind"] = event.InvolvedObject.Kind labels["name"] = event.InvolvedObject.Name