Alertmanager template not getting interpreted

13 views
Skip to first unread message

Gergely Brautigam

unread,
Sep 4, 2020, 10:18:46 AM9/4/20
to Prometheus Users
Hi folks.

I was wondering if anyone came around something like this. I have an alert in alertmanager which has a Go template like this:


    - alert: Critical
      annotations:
        description: 'Blablabla (pod: ({{$labels.namespace}}/{{$labels.pod}})), it has a current value: {{ $value | humanize }}.'
      expr: <whatever>
      for: 5m
      labels:
        severity: '{{- if match "bla-" $labels.namespace }} error {{- else -}} critical {{- end -}}'
        category: '{{- if match "bla-" $labels.namespace }} deployment {{- else -}} infrastructure {{- end -}}'
        server_id: '{{ if match "bla-" $labels.namespace }} {{ reReplaceAll "bla-(.*)" "$1" $labels.namespace }} {{- else -}} {{- end -}}'

What happens is that the whole thing in severity, category and server_id is just being displayed as is. Like it was just a string and not a Go template. while the templating in description is working perfectly fine.

What's wrong here? Is some kind of config missing from somewhere? Is the syntax incorrect? I did try '{{ `{{...}}` }}' as well, but no cigar.
Reply all
Reply to author
Forward
0 new messages