Yes. Below is my Alertmanagers config. So it’s sth. to do with the template. 
Any advice what shall I change in the template below?

global:
  resolve_timeout: 5m
receivers:
- name: prometheus-msteams
  webhook_configs:
  - url: "http://localhost:2000/testChannel";
    send_resolved: true
route:
  receiver: prometheus-msteams 
  group_by: ['alertname’]


_______________
card.tmpl

{{ define "teams.card" }}
{
  "@type": "MessageCard",
  "@context": "http://schema.org/extensions <http://schema.org/extensions>",
  "themeColor": "{{- if eq .Status "resolved" -}}2DC72D
                 {{- else if eq .Status "firing" -}}
                    {{- if eq .CommonLabels.severity "critical" -}}8C1A1A
                    {{- else if eq .CommonLabels.severity "warning" -}}FFA500
                    {{- else -}}808080{{- end -}}
                 {{- else -}}808080{{- end -}}",
  "summary": "Prometheus Alerts",
  "title": "Prometheus Alert ({{ .Status }})",
  "sections": [ {{$externalUrl := .ExternalURL}}
  {{- range $index, $alert := .Alerts }}{{- if $index }},{{- end }}
    { 
      "facts": [
        {{- range $key, $value := $alert.Annotations }}
        {
          "name": "{{ reReplaceAll "_" "\\\\_" $key }}",
          "value": "{{ reReplaceAll "_" "\\\\_" $value }}"
        },
        {{- end -}}
        {{$c := counter}}{{ range $key, $value := $alert.Labels }}{{if call 
$c}},{{ end }}
        {
          "name": "{{ reReplaceAll "_" "\\\\_" $key }}",
          "value": "{{ reReplaceAll "_" "\\\\_" $value }}"
        }
        {{- end }}
      ],
      "markdown": true
    }
    {{- end }}
  ]
}
{{ end }}






> On Jun 3, 2020, at 4:59 AM, Brian Candler <[email protected]> wrote:
> 
> It's nothing to do with alertmanager, because alertmanager does not support 
> any sort of templating for webhooks.  You haven't shown your alertmanager 
> config, but I presume it's something like this:
> 
> receivers:
> - name: 'prometheus-msteams'
>   webhook_configs:
>   - send_resolved: true
>     url: 'http://localhost:2000/testChannel
> 
> So, alertmanager sends a fixed-format JSON message to this destination.  If 
> you have a problem with the data after this point, it must be down to the 
> prometheus-msteams and its use of that template you showed.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Prometheus Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/prometheus-users/c7e6e2a2-ea2f-4e65-9b2c-b62f8710b2bc%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/prometheus-users/c7e6e2a2-ea2f-4e65-9b2c-b62f8710b2bc%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/015AD2D9-ECE1-4496-BEA2-49BD26F8B299%40gmail.com.

Reply via email to