fix: improve webhook notifications for all providers

- Show full list of grouped alerts for Discord, Slack, Teams, etc (not just Telegram)
- Properly escape newlines in grouped alert messages to prevent JSON parsing errors
- Ensure consistent formatting across all webhook providers
- Address issue where only custom templates showed complete alert lists

All webhook providers now display the same detailed grouped alert format with bullet points showing each alert's resource and value.
This commit is contained in:
Pulse Monitor
2025-08-17 09:01:57 +00:00
parent 8e72d432c1
commit b00e86fb8f
+9 -2
View File
@@ -493,9 +493,16 @@ func (n *NotificationManager) sendGroupedWebhook(webhook WebhookConfig, alertLis
}
if templateFound {
// Modify message if multiple alerts
// Modify message if multiple alerts - show full list with escaped newlines
if len(alertList) > 1 {
alert.Message = fmt.Sprintf("%s (and %d more alerts)", alert.Message, len(alertList)-1)
summary := alert.Message
otherAlerts := []string{}
for i := 1; i < len(alertList); i++ {
otherAlerts = append(otherAlerts, fmt.Sprintf("• %s: %.1f%%", alertList[i].ResourceName, alertList[i].Value))
}
if len(otherAlerts) > 0 {
alert.Message = fmt.Sprintf("%s\\n\\n🔔 All %d alerts:\\n%s", summary, len(alertList), strings.Join(otherAlerts, "\\n"))
}
}
// Prepare data and generate payload