alerta-contrib/plugins/msteams/example-payload.json.j2
Jarno Huuskonen e3e3faec73 Msteams MS_TEAMS_PAYLOAD (#288)
* msteams: Set pymsteams http_timeout to MS_TEAMS_DEFAULT_TIMEOUT(7s) instead of
default 60s.

* msteams: refactor Jinja2 template loading to _load_template function.

* msteams: Add 'security' color to MS_TEAMS_DEFAULT_COLORS_MAP

* msteams: MS_TEAMS_PAYLOAD: use custom json payload for msteams messagecard
and use requests.post to send json payload to msteams. If MS_TEAMS_PAYLOAD
is not set continue to use pymsteams for creating/sending connectorcard.

* msteams: Add example for MS_TEAMS_PAYLOAD.
2019-08-01 09:23:32 +02:00

47 lines
1.6 KiB
Django/Jinja

{
"@type": "MessageCard",
"@context": "https://schema.org/extensions",
"summary": "{{ alert.status|capitalize }} {{ alert.resource }} / {{ alert.service|join(',') }}",
"themeColor": "{{ color }}",
"title": "[{{ alert.status|capitalize }}] {{ alert.environment }} {{ alert.service|join(',') }} {{ alert.severity|upper }} - {{ alert.event }} on {{ alert.resource }}",
"sections": [
{
"facts": [
{
"name": "Resource:",
"value": "**{{ alert.resource }}**{% 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(',') }}**"
}
{%- if alert.origin %}
,{
"name": "Origin:",
"value": "{{ alert.origin }}"
}{% endif %}
]
}
{%- if (alert.status and alert.status == 'open') and alert.text %}
,{
"text": "```{{ alert.text }}```"
}{% endif %}
]
{%- if alert.status and alert.status in [ 'open', 'ack', 'assign' ] %}
,"potentialAction": [
{%- if headers and actions %}
{%- for act in actions %}
{
"@type": "{{ act['type'] }}",
"name": "{{ act['name'] }}",
"target": "{{ act['target'] }}",
"headers": {{ headers }},
"body": {{ act['body'] }}
},{% endfor %}{% endif %}
{
"@type": "OpenUri",
"name": "View in Alerta",
"targets": [ { "os": "default", "uri": "{{ url }}" } ]
}
]{% endif %}
}