alertmanager/template/default.tmpl

220 lines
7.9 KiB
Cheetah
Raw Normal View History

{{ define "__alertmanager" }}Alertmanager{{ end }}
{{ define "__alertmanagerURL" }}{{ .ExternalURL }}/#/alerts?receiver={{ .Receiver | urlquery }}{{ end }}
2015-11-26 17:19:46 +00:00
{{ define "__subject" }}[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .GroupLabels.SortedPairs.Values | join " " }} {{ if gt (len .CommonLabels) (len .GroupLabels) }}({{ with .CommonLabels.Remove .GroupLabels.Names }}{{ .Values | join " " }}{{ end }}){{ end }}{{ end }}
2015-11-26 17:19:46 +00:00
{{ define "__description" }}{{ end }}
2016-01-05 19:52:08 +00:00
{{ define "__text_alert_list" }}{{ range . }}Labels:
{{ range .Labels.SortedPairs }} - {{ .Name }} = {{ .Value }}
2016-01-05 19:52:08 +00:00
{{ end }}Annotations:
{{ range .Annotations.SortedPairs }} - {{ .Name }} = {{ .Value }}
2016-02-16 14:58:18 +00:00
{{ end }}Source: {{ .GeneratorURL }}
2015-11-26 17:19:46 +00:00
{{ end }}{{ end }}
{{ define "__text_alert_list_markdown" }}{{ range . }}
Labels:
{{ range .Labels.SortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end }}
Annotations:
{{ range .Annotations.SortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end }}
Source: {{ .GeneratorURL }}
{{ end }}
{{ end }}
2015-10-11 11:32:34 +00:00
2015-11-25 14:49:26 +00:00
{{ define "slack.default.title" }}{{ template "__subject" . }}{{ end }}
2015-11-30 12:52:41 +00:00
{{ define "slack.default.username" }}{{ template "__alertmanager" . }}{{ end }}
{{ define "slack.default.fallback" }}{{ template "slack.default.title" . }} | {{ template "slack.default.titlelink" . }}{{ end }}
{{ define "slack.default.callbackid" }}{{ end }}
{{ define "slack.default.pretext" }}{{ end }}
2015-11-26 17:19:46 +00:00
{{ define "slack.default.titlelink" }}{{ template "__alertmanagerURL" . }}{{ end }}
{{ define "slack.default.iconemoji" }}{{ end }}
{{ define "slack.default.iconurl" }}{{ end }}
2015-11-30 12:52:41 +00:00
{{ define "slack.default.text" }}{{ end }}
{{ define "slack.default.footer" }}{{ end }}
2015-10-11 11:32:34 +00:00
2015-11-26 17:19:46 +00:00
{{ define "pagerduty.default.description" }}{{ template "__subject" . }}{{ end }}
2015-11-25 14:49:26 +00:00
{{ define "pagerduty.default.client" }}{{ template "__alertmanager" . }}{{ end }}
{{ define "pagerduty.default.clientURL" }}{{ template "__alertmanagerURL" . }}{{ end }}
2015-11-26 17:19:46 +00:00
{{ define "pagerduty.default.instances" }}{{ template "__text_alert_list" . }}{{ end }}
2015-10-11 11:32:34 +00:00
{{ define "opsgenie.default.message" }}{{ template "__subject" . }}{{ end }}
{{ define "opsgenie.default.description" }}{{ .CommonAnnotations.SortedPairs.Values | join " " }}
{{ if gt (len .Alerts.Firing) 0 -}}
Alerts Firing:
{{ template "__text_alert_list" .Alerts.Firing }}
{{- end }}
{{ if gt (len .Alerts.Resolved) 0 -}}
Alerts Resolved:
{{ template "__text_alert_list" .Alerts.Resolved }}
{{- end }}
{{- end }}
2015-11-26 17:19:46 +00:00
{{ define "opsgenie.default.source" }}{{ template "__alertmanagerURL" . }}{{ end }}
2015-11-24 22:29:25 +00:00
2015-11-26 17:19:46 +00:00
{{ define "wechat.default.message" }}{{ template "__subject" . }}
{{ .CommonAnnotations.SortedPairs.Values | join " " }}
{{ if gt (len .Alerts.Firing) 0 -}}
Alerts Firing:
{{ template "__text_alert_list" .Alerts.Firing }}
{{- end }}
{{ if gt (len .Alerts.Resolved) 0 -}}
Alerts Resolved:
{{ template "__text_alert_list" .Alerts.Resolved }}
{{- end }}
AlertmanagerUrl:
{{ template "__alertmanagerURL" . }}
{{- end }}
{{ define "wechat.default.to_user" }}{{ end }}
{{ define "wechat.default.to_party" }}{{ end }}
{{ define "wechat.default.to_tag" }}{{ end }}
{{ define "wechat.default.agent_id" }}{{ end }}
{{ define "victorops.default.state_message" }}{{ .CommonAnnotations.SortedPairs.Values | join " " }}
{{ if gt (len .Alerts.Firing) 0 -}}
Alerts Firing:
{{ template "__text_alert_list" .Alerts.Firing }}
{{- end }}
{{ if gt (len .Alerts.Resolved) 0 -}}
Alerts Resolved:
{{ template "__text_alert_list" .Alerts.Resolved }}
{{- end }}
{{- end }}
{{ define "victorops.default.entity_display_name" }}{{ template "__subject" . }}{{ end }}
{{ define "victorops.default.monitoring_tool" }}{{ template "__alertmanager" . }}{{ end }}
{{ define "pushover.default.title" }}{{ template "__subject" . }}{{ end }}
{{ define "pushover.default.message" }}{{ .CommonAnnotations.SortedPairs.Values | join " " }}
{{ if gt (len .Alerts.Firing) 0 }}
Alerts Firing:
{{ template "__text_alert_list" .Alerts.Firing }}
{{ end }}
{{ if gt (len .Alerts.Resolved) 0 }}
Alerts Resolved:
{{ template "__text_alert_list" .Alerts.Resolved }}
{{ end }}
{{ end }}
{{ define "pushover.default.url" }}{{ template "__alertmanagerURL" . }}{{ end }}
{{ define "sns.default.subject" }}{{ template "__subject" . }}{{ end }}
{{ define "sns.default.message" }}{{ .CommonAnnotations.SortedPairs.Values | join " " }}
{{ if gt (len .Alerts.Firing) 0 }}
Alerts Firing:
{{ template "__text_alert_list" .Alerts.Firing }}
{{ end }}
{{ if gt (len .Alerts.Resolved) 0 }}
Alerts Resolved:
{{ template "__text_alert_list" .Alerts.Resolved }}
{{ end }}
{{ end }}
Adding telegram support (#2827) * added telegram config in notifiers Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com> * added telegram config to config.go Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com> * added package telegram to notify and initialization in cmd Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com> * added telegram.default.message Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com> * added telegram template to notifiers.go Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com> * added message rendering from template to telegram integration Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com> * documentation for telegram_configs Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com> * added tests for telegram Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com> * fixed config_test.go Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com> * added valid parse_mode list to the error log Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com> * made use of httpconfig, moved telegram client creation to New func, changed message truncation to 4096 chars Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com> * changed supported values for telegram config Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com> * added mock url for telegram tests to pass Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com> * added api_url check to telegram config Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com> * changed bot_token type to secret Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com> * removed extra emptyline Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com> * convert bot_token to string in telegram client creation Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com> * updated configuration.md Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com> * fixed mixed up errors Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com> * check telegram api url without conversion to string Signed-off-by: timmilesdw <tuktamyshev.t0308@gmail.com>
2022-02-22 16:51:02 +00:00
{{ define "telegram.default.message" }}
{{ if gt (len .Alerts.Firing) 0 }}
Alerts Firing:
{{ template "__text_alert_list" .Alerts.Firing }}
{{ end }}
{{ if gt (len .Alerts.Resolved) 0 }}
Alerts Resolved:
{{ template "__text_alert_list" .Alerts.Resolved }}
{{ end }}
{{ end }}
{{ define "discord.default.content" }}{{ end }}
{{ define "discord.default.title" }}{{ template "__subject" . }}{{ end }}
{{ define "discord.default.message" }}
{{ if gt (len .Alerts.Firing) 0 }}
Alerts Firing:
{{ template "__text_alert_list" .Alerts.Firing }}
{{ end }}
{{ if gt (len .Alerts.Resolved) 0 }}
Alerts Resolved:
{{ template "__text_alert_list" .Alerts.Resolved }}
{{ end }}
{{ end }}
{{ define "webex.default.message" }}{{ .CommonAnnotations.SortedPairs.Values | join " " }}
{{ if gt (len .Alerts.Firing) 0 }}
Alerts Firing:
{{ template "__text_alert_list" .Alerts.Firing }}
{{ end }}
{{ if gt (len .Alerts.Resolved) 0 }}
Alerts Resolved:
{{ template "__text_alert_list" .Alerts.Resolved }}
{{ end }}
{{ end }}
{{ define "msteams.default.summary" }}{{ template "__subject" . }}{{ end }}
{{ define "msteams.default.title" }}{{ template "__subject" . }}{{ end }}
{{ define "msteams.default.text" }}
{{ if gt (len .Alerts.Firing) 0 }}
# Alerts Firing:
{{ template "__text_alert_list_markdown" .Alerts.Firing }}
{{ end }}
{{ if gt (len .Alerts.Resolved) 0 }}
# Alerts Resolved:
{{ template "__text_alert_list_markdown" .Alerts.Resolved }}
{{ end }}
{{ end }}
{{ define "msteamsv2.default.title" }}{{ template "__subject" . }}{{ end }}
{{ define "msteamsv2.default.text" }}
{{ if gt (len .Alerts.Firing) 0 }}
# Alerts Firing:
{{ template "__text_alert_list_markdown" .Alerts.Firing }}
{{ end }}
{{ if gt (len .Alerts.Resolved) 0 }}
# Alerts Resolved:
{{ template "__text_alert_list_markdown" .Alerts.Resolved }}
{{ end }}
{{ end }}
{{ define "jira.default.summary" }}{{ template "__subject" . }}{{ end }}
{{ define "jira.default.description" }}
{{ if gt (len .Alerts.Firing) 0 }}
# Alerts Firing:
{{ template "__text_alert_list_markdown" .Alerts.Firing }}
{{ end }}
{{ if gt (len .Alerts.Resolved) 0 }}
# Alerts Resolved:
{{ template "__text_alert_list_markdown" .Alerts.Resolved }}
{{ end }}
{{ end }}
{{- define "jira.default.priority" -}}
{{- $priority := "" }}
{{- range .Alerts.Firing -}}
{{- $severity := index .Labels "severity" -}}
{{- if (eq $severity "critical") -}}
{{- $priority = "High" -}}
{{- else if (and (eq $severity "warning") (ne $priority "High")) -}}
{{- $priority = "Medium" -}}
{{- else if (and (eq $severity "info") (eq $priority "")) -}}
{{- $priority = "Low" -}}
{{- end -}}
{{- end -}}
{{- if eq $priority "" -}}
{{- range .Alerts.Resolved -}}
{{- $severity := index .Labels "severity" -}}
{{- if (eq $severity "critical") -}}
{{- $priority = "High" -}}
{{- else if (and (eq $severity "warning") (ne $priority "High")) -}}
{{- $priority = "Medium" -}}
{{- else if (and (eq $severity "info") (eq $priority "")) -}}
{{- $priority = "Low" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $priority -}}
{{- end -}}
{{ define "rocketchat.default.title" }}{{ template "__subject" . }}{{ end }}
{{ define "rocketchat.default.alias" }}{{ template "__alertmanager" . }}{{ end }}
{{ define "rocketchat.default.titlelink" }}{{ template "__alertmanagerURL" . }}{{ end }}
{{ define "rocketchat.default.emoji" }}{{ end }}
{{ define "rocketchat.default.iconurl" }}{{ end }}
{{ define "rocketchat.default.text" }}{{ end }}