Verified Commit 62353b44 authored by Quentin Duchemin's avatar Quentin Duchemin
Browse files

Further improve Mattermost alert appearance

parent dbe4e755
......@@ -3,6 +3,8 @@ ARG VERSION=v0.22.2
FROM prom/alertmanager:${VERSION}
COPY ./entrypoint.sh /entrypoint.sh
COPY ./templates.tpl /config/templates.tpl
# Initial image uses user nobody which cannot chmod nor sed
USER root
RUN chmod +x /entrypoint.sh
......
......@@ -33,9 +33,9 @@ route:
# already critical.
inhibit_rules:
- source_matchers:
- severity="critical"
- severity="critical"
target_matchers:
- severity="warning"
- severity="warning"
# Apply inhibition if the alertname is the same.
# CAUTION:
# If all label names listed in `equal` are missing
......@@ -46,4 +46,29 @@ inhibit_rules:
receivers:
- name: 'mattermost'
slack_configs:
- channel: '$MATTERMOST_CHANNEL'
- channel: '$MATTERMOST_CHANNEL'
icon_emoji: ":thaenkin:"
username: "AlertManager"
color: '{{ if eq .CommonLabels.severity "warning" -}}warning{{- else if eq .CommonLabels.severity "critical" -}}danger{{- end -}}'
title: "### {{ .CommonLabels.alertname }}"
text: "Summary : {{ .CommonAnnotations.summary }}"
fields:
- title: "Description"
value: "{{ .CommonAnnotations.description }}"
- title: "Criticity"
value: "{{ .CommonLabels.severity }}"
actions:
- type: button
text: ':chart_with_upwards_trend: See dashboard'
url: '{{ (index .Alerts 0).Annotations.dashboard }}'
style: primary
- type: button
text: ':no_bell: Silence'
url: '{{ template "__alert_silence_link" . }}'
style: danger
- type: button
text: ':grey_question: Documentation'
url: "https://wiki.picasoft.net/doku.php?id=technique:adminsys:monitoring:metrologie:stack-picasoft"
templates:
- templates.tpl
{{ define "__alert_silence_link" -}}
{{ .ExternalURL }}/#/silences/new?filter=%7B
{{- range .CommonLabels.SortedPairs -}}
{{- if ne .Name "alertname" -}}
{{- .Name }}%3D"{{- .Value -}}"%2C%20
{{- end -}}
{{- end -}}
alertname%3D"{{ .CommonLabels.alertname }}"%7D
{{- end }}
......@@ -220,7 +220,8 @@ groups:
labels:
severity: critical
annotations:
summary: "{{ $labels.instance }} is down"
summary: "Service down"
description: "{{ $labels.instance }} is down for more than 2 minutes"
- alert: PostfixRejection
# As a test, alert when there is any rejection. If too much alert we will raise the threshold
expr: rate(postfix_smtpd_messages_rejected_total[5m]) > 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment