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 <joey.orlando@grafana.com> Co-authored-by: Joey Orlando <joseph.t.orlando@gmail.com>
This commit is contained in:
parent
b2bb408dd7
commit
44171fc7b6
1 changed files with 15 additions and 3 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue