From acd656c6ea4ccf96788534eb1e485a0dc7175ada Mon Sep 17 00:00:00 2001 From: Pablo Ovelleiro Corral Date: Fri, 4 Nov 2022 07:45:37 +0100 Subject: [PATCH] Skip resolved messsages --- main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.go b/main.go index c16ca88..321b5f5 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "github.com/prometheus/alertmanager/template" + "github.com/prometheus/common/model" "log" "net/http" "os" @@ -30,6 +31,11 @@ func WebhookHandler(w http.ResponseWriter, r *http.Request) { for _, alert := range payload.Alerts { + // Skip resolved messages + if alert.Status == string(model.AlertResolved) { + continue + } + log.Println(alert) req, err := http.NewRequest("POST", os.Getenv("NTFY_TOPIC"), strings.NewReader(alert.Annotations["description"]))