I’ve setup alerts, and they’re working when I’m using no template by leaving the message box empty.
However, after a long search I’ve found that you can pick which template is used, by adding the template to the message panel in a certain contact point.
So, I’ve created a Message Template, that is an exact copy of the default one, which looks like this:
{{ define "test_alert" }}
[{{.Status}}] {{ .Labels.alertname }}
Labels:
{{ range .Labels.SortedPairs }}
{{ .Name }}: {{ .Value }}
{{ end }}
{{ if gt (len .Annotations) 0 }}
Annotations:
{{ range .Annotations.SortedPairs }}
{{ .Name }}: {{ .Value }}
{{ end }}
{{ end }}
{{ if gt (len .SilenceURL ) 0 }}
Silence alert: {{ .SilenceURL }}
{{ end }}
{{ if gt (len .DashboardURL ) 0 }}
Go to dashboard: {{ .DashboardURL }}
{{ end }}
{{ end }}
Unfortunately, the messages that arrive in Slack, look like this:
[FIRING:1] (Test VC test)
[<no value>] <no value>
Labels:
When using no template, the message looks like this:
**Firing**
Value: [ metric='Name of cronjob 1' labels={job=Name of cronjob} value=77777], [ metric='Name of cronjob 2' labels={job=Name of cronjob} value=77777], [ metric='Name of cronjob 3' labels={job=Name of cronjob} value=77777], [ metric='Name of cronjob 4' labels={job=Name of cronjob} value=77777],
Labels:
- alertname = Test VC
- test = test
Annotations:
I would like to have the message look like this:
**Firing**
Value:
[ metric='Name of cronjob 1' value=77777],
[ metric='Name of cronjob 2' value=77777],
[ metric='Name of cronjob 3' value=77777],
[ metric='Name of cronjob 4' value=77777],
Labels:
- alertname = Test VC
- test = test
Annotations:
My questions are:
- How can I see/know what variables I can use between the
{{}}
? - Why are all these values showing as
<no value>
- How can I split the Array of Values in the message?
- Is there some more documentation besides this, that I’m missing?