فهرست منبع

feat(alerting): add basic body for webhooks

bergquist 9 سال پیش
والد
کامیت
3c4d2b8ca1
1فایلهای تغییر یافته به همراه9 افزوده شده و 1 حذف شده
  1. 9 1
      pkg/services/alerting/notifier.go

+ 9 - 1
pkg/services/alerting/notifier.go

@@ -73,11 +73,19 @@ type WebhookNotifier struct {
 
 func (this *WebhookNotifier) Dispatch(alertResult *AlertResult) {
 	this.log.Info("Sending webhook")
+
+	bodyJSON := simplejson.New()
+	bodyJSON.Set("name", alertResult.AlertJob.Rule.Name)
+	bodyJSON.Set("state", alertResult.State)
+	bodyJSON.Set("trigged", alertResult.TriggeredAlerts)
+
+	body, _ := bodyJSON.MarshalJSON()
+
 	cmd := &m.SendWebhook{
 		Url:      this.Url,
 		User:     this.User,
 		Password: this.Password,
-		Body:     alertResult.Description,
+		Body:     string(body),
 	}
 
 	bus.Dispatch(cmd)