From 7999cd0189538cef4792c61f99129ac4bf03d6d4 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")) } }