From 5b3ff90377297413c30aad634d9d588afb67ca36 Mon Sep 17 00:00:00 2001 From: michael-az <57443891+michael-az@users.noreply.github.com> Date: Wed, 18 Dec 2019 14:03:59 +0100 Subject: [PATCH] Alerting: Add more information to webhook notifications (#20420) Adds the orgId, dashboardId and panelId of the Webhook alert notifier. --- docs/sources/alerting/notifications.md | 33 +++++++++++++--------- pkg/services/alerting/notifiers/webhook.go | 3 ++ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/docs/sources/alerting/notifications.md b/docs/sources/alerting/notifications.md index 4e12e363835..fe7dba957d4 100644 --- a/docs/sources/alerting/notifications.md +++ b/docs/sources/alerting/notifications.md @@ -111,22 +111,27 @@ Example json body: ```json { - "title": "My alert", - "ruleId": 1, - "ruleName": "Load peaking!", - "ruleUrl": "http://url.to.grafana/db/dashboard/my_dashboard?panelId=2", - "state": "alerting", - "imageUrl": "http://s3.image.url", - "message": "Load is peaking. Make sure the traffic is real and spin up more webfronts", - "evalMatches": [ + "dashboardId":1, + "evalMatches":[ { - "metric": "requests", - "tags": {}, - "value": 122 + "value":1, + "metric":"Count", + "tags":{} } - ] -} -``` + ], + "imageUrl":"https://grafana.com/assets/img/blog/mixed_styles.png", + "message":"Notification Message", + "orgId":1, + "panelId":2, + "ruleId":1, + "ruleName":"Panel Title alert", + "ruleUrl":"http://localhost:3000/d/hZ7BuVbWz/test-dashboard?fullscreen\u0026edit\u0026tab=alert\u0026panelId=2\u0026orgId=1", + "state":"alerting", + "tags":{ + "tag name":"tag value" + }, + "title":"[Alerting] Panel Title alert" +}``` - **state** - The possible values for alert state are: `ok`, `paused`, `alerting`, `pending`, `no_data`. diff --git a/pkg/services/alerting/notifiers/webhook.go b/pkg/services/alerting/notifiers/webhook.go index 2e907d5e912..5b2dcf53b80 100644 --- a/pkg/services/alerting/notifiers/webhook.go +++ b/pkg/services/alerting/notifiers/webhook.go @@ -80,6 +80,9 @@ func (wn *WebhookNotifier) Notify(evalContext *alerting.EvalContext) error { bodyJSON.Set("ruleName", evalContext.Rule.Name) bodyJSON.Set("state", evalContext.Rule.State) bodyJSON.Set("evalMatches", evalContext.EvalMatches) + bodyJSON.Set("orgId", evalContext.Rule.OrgID) + bodyJSON.Set("dashboardId", evalContext.Rule.DashboardID) + bodyJSON.Set("panelId", evalContext.Rule.PanelID) tags := make(map[string]string)