fix: improve webhook test notifications with realistic values

- Use realistic test values (85.5% CPU, 80% threshold) instead of zeros
- Set alert level to 'warning' instead of 'info' for better visibility
- Add 5-minute duration to test alerts for realistic testing
- Improve test message to be more descriptive
- Fix empty message text issue in Telegram webhooks

The webhook system now sends proper test notifications that accurately
simulate real alerts, making it easier to verify webhook configurations.
This commit is contained in:
Pulse Monitor
2025-08-16 21:46:33 +00:00
parent 7281828787
commit 91f60ed9b8
+9 -9
View File
@@ -1094,19 +1094,19 @@ func (n *NotificationManager) SendTestNotification(method string) error {
// SendTestWebhook sends a test notification to a specific webhook
func (n *NotificationManager) SendTestWebhook(webhook WebhookConfig) error {
// Create a test alert for webhook testing
// Create a test alert for webhook testing with realistic values
testAlert := &alerts.Alert{
ID: "test-webhook-" + webhook.ID,
Type: "test",
Level: "info",
Type: "cpu",
Level: "warning",
ResourceID: "webhook-test",
ResourceName: "Webhook Test",
ResourceName: "Test Alert",
Node: "test-node",
Instance: "pulse-server",
Message: fmt.Sprintf("Testing webhook: %s", webhook.Name),
Value: 0,
Threshold: 0,
StartTime: time.Now(),
Instance: "pulse-monitoring",
Message: fmt.Sprintf("This is a test alert from Pulse to verify your %s webhook is working correctly", webhook.Name),
Value: 85.5,
Threshold: 80.0,
StartTime: time.Now().Add(-5 * time.Minute), // Alert started 5 minutes ago
LastSeen: time.Now(),
Metadata: map[string]interface{}{
"webhookName": webhook.Name,