-
Notifications
You must be signed in to change notification settings - Fork 171
/
example-payload.json.j2
54 lines (54 loc) · 2.13 KB
/
example-payload.json.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{
"@type": "MessageCard",
"@context": "https://schema.org/extensions",
"summary": "{{ alert.status|capitalize }} {{ alert.resource|replace('\\', '\\\\') }} / {{ alert.service|join(',')|replace('\\', '\\\\') }}",
"themeColor": "{{ color }}",
"title": "[{{ alert.status|capitalize }}] {{ alert.environment }} {{ alert.service|join(',')|replace('\\', '\\\\') }} {{ alert.severity|upper }} - {{ alert.event }} on {{ alert.resource|replace('\\', '\\\\') }}",
"sections": [
{
"facts": [
{
"name": "Resource:",
"value": "**{{ alert.resource|replace('\\', '\\\\') }}**{% if alert.attributes['hostaddress'] or alert.attributes['hostaddress6'] %} ({{ alert.attributes['hostaddress'] }}{% if alert.attributes['hostaddress6'] %} / {{ alert.attributes['hostaddress6'] }}{% endif %}){% endif %}"
},
{
"name": "Service(s):",
"value": "**{{ alert.service|join(',')|replace('\\', '\\\\') }}**"
}
{%- if alert.origin %}
,{
"name": "Origin:",
"value": "{{ alert.origin|replace('\\', '\\\\') }}"
}{% endif %}
]
}
{%- if (alert.status and alert.status == 'open') and alert.text %}
,{
"text": "```{{ alert.text|replace('\\', '\\\\') }}```"
}{% endif %}
]
{%- if alert.status and alert.status in [ 'open', 'ack', 'assign' ] %}
,"potentialAction": [
{%- if headers and webhook_url %}
{%- for act in [ 'ack', 'close' ] %}
{
"@type": "HttpPOST",
"name": "{{ act|capitalize }}",
"target": "{{ webhook_url }}",
"headers": {{ headers }},
"body": "{ \"action\": \"{{ act }}\", \"alert_id\": \"{{ alert.id }}\" }"
},{% endfor %}
{
"@type": "HttpPOST",
"name": "Blackout",
"target": "{{ webhook_url }}",
"headers": {{ headers }},
"body": "{ \"action\": \"blackout\", \"environment\": \"{{ alert.environment }}\", \"resource\": \"{{ alert.resource|replace('\\', '\\\\') }}\", \"event\": \"{{ alert.event }}\" }"
},{% endif %}
{
"@type": "OpenUri",
"name": "View in Alerta",
"targets": [ { "os": "default", "uri": "{{ url }}" } ]
}
]{% endif %}
}