From aa4a26d42cb773fdaafe9ae9b46b1f298455b2a2 Mon Sep 17 00:00:00 2001 From: Pulse Monitor Date: Sun, 17 Aug 2025 07:55:44 +0000 Subject: [PATCH] fix: escape newlines in grouped alert messages for JSON webhook templates Webhooks weren't being sent because the grouped alert message contained actual newlines which broke JSON parsing in custom templates. Changed to use escaped newlines (\n) which work properly in JSON strings. --- internal/notifications/notifications.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/notifications/notifications.go b/internal/notifications/notifications.go index 26fd10f43..ab6229d24 100644 --- a/internal/notifications/notifications.go +++ b/internal/notifications/notifications.go @@ -195,7 +195,7 @@ func (n *NotificationManager) SendAlert(alert *alerts.Alert) { n.mu.Lock() defer n.mu.Unlock() - log.Debug(). + log.Info(). Str("alertID", alert.ID). Bool("enabled", n.enabled). Int("webhooks", len(n.webhooks)). @@ -210,7 +210,7 @@ func (n *NotificationManager) SendAlert(alert *alerts.Alert) { // Check cooldown lastTime, exists := n.lastNotified[alert.ID] if exists && time.Since(lastTime) < n.cooldown { - log.Debug(). + log.Info(). Str("alertID", alert.ID). Dur("timeSince", time.Since(lastTime)). Dur("cooldown", n.cooldown). @@ -445,7 +445,7 @@ func (n *NotificationManager) sendGroupedWebhook(webhook WebhookConfig, alertLis otherAlerts = append(otherAlerts, fmt.Sprintf("• ... and %d more", len(alertList)-4)) } if len(otherAlerts) > 0 { - alert.Message = fmt.Sprintf("%s\n\nšŸ”” Other alerts:\n%s", summary, strings.Join(otherAlerts, "\n")) + alert.Message = fmt.Sprintf("%s\\n\\nšŸ”” Other alerts:\\n%s", summary, strings.Join(otherAlerts, "\\n")) } }