From c61b41c321dff16c2f852fae9795b58e21edd7e7 Mon Sep 17 00:00:00 2001 From: Quentin Duchemin <quentinduchemin@tuta.io> Date: Sun, 29 Aug 2021 20:18:04 +0200 Subject: [PATCH] Slack buttons are not compatible anymore with Mattermost, use fields --- pica-metrologie/alertmanager/alertmanager.yml | 48 +++++++++---------- pica-metrologie/alertmanager/templates.tpl | 4 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/pica-metrologie/alertmanager/alertmanager.yml b/pica-metrologie/alertmanager/alertmanager.yml index fd5372c2..7ae4c83b 100644 --- a/pica-metrologie/alertmanager/alertmanager.yml +++ b/pica-metrologie/alertmanager/alertmanager.yml @@ -46,29 +46,29 @@ inhibit_rules: receivers: - name: 'mattermost' slack_configs: - - 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" + - 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: "**{{ .CommonLabels.severity }}** : {{ .CommonAnnotations.summary }}" + fields: + - title: "Description" + value: "{{ .CommonAnnotations.description }}" + # Would be better with buttons but Slack new buttons are not + # yet compatible with Mattermost interactive messages model + - title: ":chart_with_upwards_trend: See the data" + value: "[Open Grafana]({{ (index .Alerts 0).Annotations.dashboard }})" + short: true + - title: ':no_bell: Silence' + value: '[Silence the alert]({{ template "__alert_silence_link" . }})' + short: true + - title: ':question: Documentation' + value: "[Show documentation](https://wiki.picasoft.net/doku.php?id=technique:adminsys:monitoring:metrologie:stack-picasoft)" + short: true + - title: ':fire: See all alerts' + value: "[AlertManager WebUI](https://alertmanager.picasoft.net)" + short: true templates: -- templates.tpl +- /config/templates.tpl diff --git a/pica-metrologie/alertmanager/templates.tpl b/pica-metrologie/alertmanager/templates.tpl index 2af54278..38636a9c 100644 --- a/pica-metrologie/alertmanager/templates.tpl +++ b/pica-metrologie/alertmanager/templates.tpl @@ -2,8 +2,8 @@ {{ .ExternalURL }}/#/silences/new?filter=%7B {{- range .CommonLabels.SortedPairs -}} {{- if ne .Name "alertname" -}} - {{- .Name }}%3D"{{- .Value -}}"%2C%20 + {{- .Name }}%3D'{{- .Value -}}'%2C%20 {{- end -}} {{- end -}} - alertname%3D"{{ .CommonLabels.alertname }}"%7D + alertname%3D'{{ .CommonLabels.alertname }}'%7D {{- end }} -- GitLab