728e39e5cd
* msteams: MS_TEAMS_INBOUNDWEBHOOK_URL MS_TEAMS_APIKEY for msteams webhook * msteams(webhook) * msteams: escape backslashes (SCOM) in example-payload.json.j2 * msteams webhook: use list not a tuple. * msteams webhook: comment tests that need mocking * msteams webhook: tests: only send Content-Type header.
55 lines
2.1 KiB
Django/Jinja
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 %}
|
|
}
|