diff --git a/main.go b/main.go index 321b5f5..0d9c478 100644 --- a/main.go +++ b/main.go @@ -33,10 +33,11 @@ func WebhookHandler(w http.ResponseWriter, r *http.Request) { // Skip resolved messages if alert.Status == string(model.AlertResolved) { + log.Printf("Skipping notification for alert: %v\n", alert) continue } - log.Println(alert) + log.Printf("Processing alert: %v\n", alert) req, err := http.NewRequest("POST", os.Getenv("NTFY_TOPIC"), strings.NewReader(alert.Annotations["description"])) if err != nil { @@ -58,6 +59,8 @@ func WebhookHandler(w http.ResponseWriter, r *http.Request) { req.SetBasicAuth(os.Getenv("NTFY_USER"), os.Getenv("NTFY_PASS")) + log.Printf("Sending request: %v\n", req) + if _, err := http.DefaultClient.Do(req); err != nil { log.Printf("Sending to %s failed: %s\n", req.RemoteAddr, err) w.WriteHeader(http.StatusBadRequest)