CommonAnnotations not working for AlertManager

3/29/2019

I'm trying to setup Alertmanager via Prometheus. I have already written my alert-rules and alertmanager.yaml file. I'm able to send alerts to slack via alertmanager.

Problem

I'm not able to beautify my alerts. I want to send description, alert name, summary with my alert.

I have tried using CommonAnnotations in order to send description, name, and summary of my alert. But unfortunately it's only working for 'DeadMansSwitch'. For all other alerts, I'm not able to see anything on slack channel.

#PrometheusRules

- alert: esWorkerACKSPM
        annotations:
          description: Buzzsaw esworkers acknowledgment per minute.
          summary: Prometheus' alert notification :- Buzzsaw average esworker acknowledgment per minute is lower than 10.
        expr: avg(bz_ackspm{broker=~"ldbb-.*", group="esworkers"}) < 10
        for: 5m
        labels:
          severity: urgent   
#alertmanager.yaml

global:
templates:
- 'https://github.com/prometheus/alertmanager/blob/master/template/default.tmpl'
route:
  group_by: ['severity']
  group_wait: 3s
  group_interval: 5s
  repeat_interval: 20s
  receiver: mail-receiver
  routes:
  - match:
      severity: urgent
    receiver: critical-mail-receiver
    routes:
receivers:
- name: 'mail-receiver'
  slack_configs:
  - api_url: https://hooks.slack.com/services/XXXXXX/XXXXX1/e7AXXXXXXopzmHNTJmL
    channel: '#alertmanager-testing'
    text: '{{ .CommonAnnotations.summary }}'
- name: 'critical-mail-receiver'
  slack_configs:
  - api_url: https://hooks.slack.com/services/T0XXXXCL/XXX6G4/VUVKZ8CnXXXXXXXzZguoXq
    channel: '#place'
    text: '{{ .CommonAnnotations.summary }} '

Expected Result :- Summary of the alert on the slack channel.

Actual Results :- Only able to see the summary of DeadMansSwitch (alert) on slack. For other alerts it's just showing

[FIRING:2] urgent (monitoring/kube-prometheus-prometheus-prometheus)
-- Rohit Yadav
kubernetes
prometheus-alertmanager
slack

0 Answers