Alert label in Alertmanager template variable name

556 views
Skip to first unread message

Kev

unread,
Apr 11, 2018, 4:10:29 AM4/11/18
to Prometheus Users
Idea is to customize notifications based on what the alert is about (e.g. from node_exporter, k8s etc.), because they generally have different labels that are useful, and it would be preferable to not print all of the labels or all of the common labels for alerts, but only valuable labels, described in specific template variables.

To that end, is it possible to reference a template variable by a label from the alert?

For example something like (this does not work):
receivers:
- name: 'slack-notifications'
  slack_configs
:
 
- channel: '#alerts'
    text
: |-
     
{{ range .Alerts }}
       
*Summary:* {{ .Annotations.summary }}
       
*Description:* {{ .Annotations.description }}
       
{{ template .Labels.template . }}
     
{{ end }}

Maybe there's a different approach to customize alert content and not write a separate receiver for each?

Brian Brazil

unread,
Apr 11, 2018, 4:12:32 AM4/11/18
to Kev, Prometheus Users
If you want to do different things for different alerts, then you should probably do that down in your alert templates rather than up in the alertmanager. In addition all of your alert labels should be valuable, if not they shouldn't be labels in the first place.

--
Reply all
Reply to author
Forward
0 new messages