Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
moved slack alert title and text to template and added link for sourc…
…e of silence button template

Signed-off-by: Sandeep Sukhani <[email protected]>
  • Loading branch information
sandeepsukhani committed Apr 21, 2020
commit 3ac303c6dc52d600aa3a0f90250db6cf9f345f1d
11 changes: 2 additions & 9 deletions prometheus-ksonnet/lib/alertmanager.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,8 @@
]
else [],

slackAlertTitle:: '[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .GroupLabels.cluster }}: {{ .GroupLabels.alertname }} ({{ .GroupLabels.namespace }})',
slackAlertText:: |||
{{ .CommonAnnotations.summary }}
{{ if .Alerts.Firing | len }}Firing alerts:
{{ range .Alerts.Firing }}- {{ .Annotations.message }}{{ .Annotations.description }}
{{ end }}{{ end }}{{ if .Alerts.Resolved | len }}Resolved alerts:
{{ range .Alerts.Resolved }}- {{ .Annotations.message }}{{ .Annotations.description }}
{{ end }}{{ end }}
|||,
slackAlertTitle:: '{{ template "__alert_title" . }}',
slackAlertText:: {{ template "__alert_text" . }},

build_slack_receiver(name, slack_channel)::
{
Expand Down
15 changes: 14 additions & 1 deletion prometheus-ksonnet/lib/files/alertmanager_config.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
{{ define "__alert_title" -}}
[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .GroupLabels.cluster }}: {{ .GroupLabels.alertname }} ({{ .GroupLabels.namespace }})
{{- end }}

{{ define "__alert_text" -}}
{{ .CommonAnnotations.summary }}
{{ if .Alerts.Firing | len }}Firing alerts:
{{ range .Alerts.Firing }}- {{ .Annotations.message }}{{ .Annotations.description }}
{{ end }}{{ end }}{{ if .Alerts.Resolved | len }}Resolved alerts:
{{ range .Alerts.Resolved }}- {{ .Annotations.message }}{{ .Annotations.description }}
{{ end }}{{ end }}
{{- end }}

# This builds the silence URL. We exclude the alertname in the range
# to avoid the issue of having trailing comma separator (%2C) at the end
# of the generated URL
# of the generated URL. Inspired from https://gist.github.com/milesbxf/e2744fc90e9c41b47aa47925f8ff6512
{{ define "__alert_silence_link" -}}
{{ .ExternalURL }}/#/silences/new?filter=%7B
{{- range .CommonLabels.SortedPairs -}}
Expand Down