From 44171fc7b6c887f5931bdd87c00f6ff00d08b7b3 Mon Sep 17 00:00:00 2001 From: sarah-spang <86264026+sarah-spang@users.noreply.github.com> Date: Thu, 23 Mar 2023 10:12:19 -0600 Subject: [PATCH] Add label and formatted JSON example (#1465) # What this PR does - Updates documentation ## Which issue(s) this PR fixes - Removed visible backticks to correct formatting - Added example of a variable that returns alert labels - Added details on how to send labels in formatted JSON --------- Co-authored-by: Joey Orlando Co-authored-by: Joey Orlando --- .../alert-behavior/outgoing-webhooks/index.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/sources/alert-behavior/outgoing-webhooks/index.md b/docs/sources/alert-behavior/outgoing-webhooks/index.md index 7931f6ea..74237bbf 100644 --- a/docs/sources/alert-behavior/outgoing-webhooks/index.md +++ b/docs/sources/alert-behavior/outgoing-webhooks/index.md @@ -38,14 +38,26 @@ the first alert in the alert group: `alert_payload` is always the first level of any variable you want to call. -The following is an example of an entry in the **Data** field that might return an alert name and description. +The following is an example of an entry in the **Data** field that would return an alert name and description. - ```json { "name": "{{ alert_payload.labels.alertname }}", "message": "{{ alert_payload.annotations.description }}" } - ``` + +The following is an example would return an alert name and the alert's labels. + + { + "alertname" : "{{ alert_payload.labels.alertname }}", + "labels" : "{{ alert_payload.labels }}" + } + +By default, this will return labels in a list format. If you'd like your labels to be sent in formatted JSON, please use `| tojson()` in your data. For example: + + { + "alertname" : "{{ alert_payload.labels.alertname }}", + "labels" : "{{ alert_payload.labels | tojson() }}" + } > **NOTE:** If you receive an error message and cannot create an outgoing webhook, verify that your JSON is > formatted correctly.