alerta_alerta-contrib/plugins/msteams/example-payload.json.j2

55 lines
2.1 KiB
Django/Jinja

{
"@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 %}
}