Customizing Prometheus AlertManager notifications in Slack

88 views
Skip to first unread message

Abraham Dhanyaraj

unread,
Oct 21, 2018, 2:12:44 PM10/21/18
to Prometheus Developers
Hi ,


I have few Win servers (Like Build, DB, App etc) where WMI is installed and configured, and able to read Metrics(based on rules like Disk Space >90) on my Prometheus dashboard.

Setup a Altermanager on the same box and I m writing Metrics (Diskspace >90) details to my Slack Channel.

route: group_by: [cluster] # If an alert isn't caught by a route, send it slack. receiver: slack routes: # Send severity=slack alerts to slack. - match: severity: critical receiver: slack receivers: - name: slack slack_configs: - api_url: 'https://hooks.slack.com/services/Token' channel: '#alerts'

And the output of Slack notification is - Actual

enter image description hereIs there a way where I can ready Machine Name - along with differentiating it with Tag Name - like Build , Db etc ?

I want notifcation to be more readable like below , (I got it from some blog) could you please suggest please ?

Expected 


alertm.PNG


Any thoughts on how to edit my AlertsManager.YML ?


Thanks,


Abraham Dhanyaraj

unread,
Oct 22, 2018, 3:01:35 PM10/22/18
to Prometheus Developers
I m able to acheive it. 


route:
group_by: [cluster]
# If an alert isn't caught by a route, send it slack.
receiver: slack_general
routes:
# Send severity=slack alerts to slack.
- match:
severity: critical
receiver: slack_general

receivers:
- name: slack_general
slack_configs:
channel: '#alerts'
username: '{{ template "slack.default.username" . }}'
color: '{{ if eq .Status "firing" }}danger{{ else }}good{{ end }}'
title: '{{ template "slack.default.title" . }}'
title_link: '{{ template "slack.default.titlelink" . }}'
pretext: '{{ .CommonAnnotations.summary }}'
text: |-
{{ range .Alerts }}
*Alert:* {{ .Annotations.summary }} - `{{ .Labels.severity }}`
*Description:* {{ .Annotations.description }}
*Details:*
{{ range .Labels.SortedPairs }} • *{{ .Name }}:* `{{ .Value }}`
{{ end }}
{{ end }}
fallback: '{{ template "slack.default.fallback" . }}'
icon_emoji: '{{ template "slack.default.iconemoji" . }}'
icon_url: '{{ template "slack.default.iconurl" . }}'

Reply all
Reply to author
Forward
0 new messages