Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Round float values in webhook payloads to 1 decimal place

rcourtmanddc787418bad
diff --git a/internal/notifications/notifications.go b/internal/notifications/notifications.go
index dbd049f42f..70f1bcc635 100644
--- a/internal/notifications/notifications.go
+++ b/internal/notifications/notifications.go
@@ -7,6 +7,7 @@ import (
"encoding/json"
"fmt"
"io"
+ "math"
"net/http"
"net/url"
"os/exec"
@@ -1615,6 +1616,10 @@ func (n *NotificationManager) prepareWebhookData(alert *alerts.Alert, customFiel
ackTime = alert.AckTime.Format(time.RFC3339)
}
+ // Round Value and Threshold to 1 decimal place for cleaner webhook payloads
+ roundedValue := math.Round(alert.Value*10) / 10
+ roundedThreshold := math.Round(alert.Threshold*10) / 10
+
return WebhookPayloadData{
ID: alert.ID,
Level: string(alert.Level),
@@ -1624,8 +1629,8 @@ func (n *NotificationManager) prepareWebhookData(alert *alerts.Alert, customFiel
Node: alert.Node,
Instance: instance,
Message: alert.Message,
- Value: alert.Value,
- Threshold: alert.Threshold,
+ Value: roundedValue,
+ Threshold: roundedThreshold,
ValueFormatted: formatMetricValue(alert.Type, alert.Value),
ThresholdFormatted: formatMetricThreshold(alert.Type, alert.Threshold),
StartTime: alert.StartTime.Format(time.RFC3339),