1
0
Fork 0

Skip resolved messsages

This commit is contained in:
Pablo Ovelleiro Corral 2022-11-04 07:45:37 +01:00
parent 911bf2fa92
commit acd656c6ea
No known key found for this signature in database
GPG key ID: F7C1D57C8464E825

View file

@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/prometheus/alertmanager/template" "github.com/prometheus/alertmanager/template"
"github.com/prometheus/common/model"
"log" "log"
"net/http" "net/http"
"os" "os"
@ -30,6 +31,11 @@ func WebhookHandler(w http.ResponseWriter, r *http.Request) {
for _, alert := range payload.Alerts { for _, alert := range payload.Alerts {
// Skip resolved messages
if alert.Status == string(model.AlertResolved) {
continue
}
log.Println(alert) log.Println(alert)
req, err := http.NewRequest("POST", os.Getenv("NTFY_TOPIC"), strings.NewReader(alert.Annotations["description"])) req, err := http.NewRequest("POST", os.Getenv("NTFY_TOPIC"), strings.NewReader(alert.Annotations["description"]))