prometheus / alertmanager

Prometheus Alertmanager
https://prometheus.io
Apache License 2.0
6.57k stars 2.14k forks source link

MSTeams integration message cards actions not supported #3642

Open rgarcia89 opened 9 months ago

rgarcia89 commented 9 months ago

With the current state of the MSTeams integration we are not able to define actions next to the title, text and summary. Due to this it is not possible to define buttons that would, for example, provide a silence functionality or a URL to Prometheus, Alertmanager, Runbook or whatever.

https://learn.microsoft.com/en-us/outlook/actionable-messages/message-card-reference#openuri-action

Environment

PatrickSpies commented 5 months ago

As a kind of workaround: We use html inside the text to add a silence-link:

      msteamsConfigs:
        - text: |2-
            {{ range $index, $alert := .Alerts }}
              {{ if $index }}
            <br />
              {{ end }}
            <hr style='border-color: #{{ if eq $.Status "resolved" }}2DC72D{{ else if eq $.Status "firing" }}{{ if eq $.CommonLabels.severity "critical" }}8C1A1A{{ else if eq $.CommonLabels.severity "error" }}FF4D00{{ else if eq $.CommonLabels.severity "warning" }}FFA500{{ else }}808080{{ end }}{{ else }}808080{{ end }}; border-width: 5px;' />
            <strong>{{ $alert.Annotations.description }}</strong><br />
            <br />
              {{ range $key, $value := $alert.Annotations }}
                {{- if and (ne $key "description") (ne $key "runbook_url") }}
            <strong>{{ $key }}</strong> {{ $value }}<br />
                {{ end -}}
              {{ end -}}
              {{- range $key, $value := $alert.Labels }}
                {{- if ne $key "prometheus" }}
            <strong>{{ $key }}</strong> {{ $value }}<br />
                {{ end -}}
              {{ end }}
              {{ if eq $.Status "firing" -}}
            <br />
            <a href="{{ $.ExternalURL }}/#/silences/new?filter=%7B{{$c := 0}}{{ range $key, $value := $alert.Labels }}{{if $c}}%22%2C%20{{ end }}{{ $c = 1 }}{{ $key }}%3D%22{{ $value }}{{- end }}%22%7D" target='_blank'><button>Silence alert</button></a><br />
              {{- end }}
            {{ end }}

image

TheMeier commented 5 months ago

See https://github.com/prometheus/alertmanager/pull/3324#issuecomment-1537879727

Support for AdaptiveCards would be nice, maybe you can provide a merge request to implement that?