Notification to MS Teams

Hello,

i successfully configured the checkmk notifification plugin with ms teams workflow.
so the messages will be send to ms teams in my “team > channel”.
but they really not looks nice.
i changed some things in the ms team notifications rule, like the macros… but one thing im missing: colors!

how can i configure that the message in ms teams, whoch will be posted as adaptive cards will be colored by state (warn = yellow, crit = red, ok = green).
i really have no ideas, how i can configure this - so help would be really appreciated :slight_smile:

Thanks

You can actually use adaptive card on teams

yes this is the dafault workflow there… webhook to channel uses adaptive card.
but they need some meta data from checkmk to color the card by status.
some things like markdown has been implemented in the ms teams notify plugin but the text cant be simply colored via them in adaptive cards.

…is something like this possible in the “msteams” notification plugin?
I am using the checkmk-enterprise version 2.3.0p21.

this would be an nicer adaptive-card view on ms teams.
i really need something colored, because the normal implementation with msteams and cmk-notifications is not very useful.

help me please :wink:

{% extends "base.json.jinja" %}

//"UP", "DOWN", or "UNREACHABLE"
// Color: GOOD, WARN, ATTENTION
{% set state_color = {'UP':'good', 'UNREACHABLE':'warning', 'DOWN':'attention'} %}

{# REMEMBER: text fields are MarkDown formatted in MS-Teams by default!!! #}
{% block content %}
{
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "1.3",
    "body": [
        {
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "width": "stretch",
                    "items": [
                        {
                            "type": "TextBlock",
                            "text": "**{{ NOTIFICATIONTYPE }}**",
                            "size": "Small",
                            "horizontalAlignment": "Left",
                            "spacing": "None",
                            "wrap": true
                        },
                        {
                            "type": "TextBlock",
                            "size": "Default",
                            "color": "Accent",
                            "spacing": "None",
                            "text": "HostName: [{{HOSTNAME}}]({{nagios_url}}/status.cgi?navbarsearch=1&host={{HOSTNAME}}*)"
                        },
                        {
                            "type": "TextBlock",
                            "size": "Large",
                            "color": "Accent",
                            "spacing": "None",
                            "text": "Priority: **{{ _HOSTRESTORE_PRIORITY }}**"
                        },
                        {
                            "type": "TextBlock",
                            "text": "**Host Notes:** {{HOSTNOTES}}",
                            "size": "Default",
                            "horizontalAlignment": "Left",
                            "spacing": "Small",
                            "wrap": true
                        }
                    ]
                },
                {
                    "type": "Column",
                    "width": "auto",
                    "items": [
                        {
                            "type": "TextBlock",
                            "text": "Status",
                            "horizontalAlignment": "Right",
                            "isSubtle": true,
                            "wrap": true,
                            "size": "Default"
                        },
                        {
                            "type": "TextBlock",
                            "text": "{{HOSTSTATE}}",
                            "horizontalAlignment": "Right",
                            "spacing": "None",
                            "size": "Large",
                            "color": "{{ state_color[HOSTSTATE] }}",
                            "wrap": true
                        }
                    ]
                }
            ]
        }{% if NOTIFICATIONCOMMENT is defined %}{% if NOTIFICATIONCOMMENT != None %},
        {
            "type": "Container",
            "separator": true,
            "items": [
                {
                    "type": "TextBlock",
                    "text": "**{{ NOTIFICATIONAUTHOR }}'s comments:**\n\n{{ NOTIFICATIONCOMMENT }}",
                    "wrap": true
                }
            ]
        }{% endif %}{% endif %}
    ],
    "speak": "<s>Host {{HOSTNAME}} is {{HOSTSTATE}}</s>",
    "actions": [
        {
            "type": "Action.OpenUrl",
            "title": "View/Acknowledge",
            "url": "{{nagios_url}}/extinfo.cgi?type=1&host={{HOSTNAME}}"
        },
        {
            "type": "Action.OpenUrl",
            "title": "Send Notification",
            "url": "{{nagios_url}}/cmd.cgi?cmd_typ=159&host={{HOSTNAME}}"
        },
        {
            "type": "Action.ShowCard",
            "title": "Show Nagios Output",
            "card": {
                "type": "AdaptiveCard",
                "body": [
                    {
                        "type": "TextBlock",
                        "wrap": true,
                        "text": "**Nagios Output:**\n\n{{ HOSTOUTPUT }}"
                    }
                ],
                "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
            }
        }
    ]
}

{% endblock %}

Hi,

have you already found a solution to this?