Skip to content

Commit

Permalink
feat: standardize the default.tmpl for all alert methodsss
Browse files Browse the repository at this point in the history
feat: point to grafana instead of alertmanager
  • Loading branch information
venkatamutyala authored Mar 17, 2023
1 parent 9351c88 commit 6d1deeb
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions customizations/template/default.tmpl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{{ define "__alertmanager" }}Alertmanager{{ end }}
{{ define "__alertmanagerURL" }}{{ .ExternalURL }}/#/glueops-test-1?receiver={{ .Receiver | urlquery }}{{ end }}
{{ define "__alertmanagerURL" }}{{ .ExternalURL }}{{ end }}

{{ 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 }}
{{ define "__subject" }}[{{ .Status | toUpper }}] {{ with index .GroupLabels "alertname" }}{{ . }}{{ end }} - {{ with index .GroupLabels "namespace" }}{{ . }}{{ end }}{{ end }}
{{ define "__description" }}{{ end }}

{{ define "__text_alert_list" }}{{ range . }}Labels:
{{ range .Labels.SortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end }}Annotations:
{{ range .Labels.SortedPairs }}{{ if ne .Name "prometheus" }} - {{ .Name }} = {{ .Value }}
{{ end }}{{ end }}Annotations:
{{ range .Annotations.SortedPairs }} - {{ .Name }} = {{ .Value }}
{{ end }}Source: {{ .GeneratorURL }}
{{ end }}
{{ end }}{{ end }}


Expand Down Expand Up @@ -40,6 +40,7 @@ Alerts Firing:
Alerts Resolved:
{{ template "__text_alert_list" .Alerts.Resolved }}
{{- end }}
Source: {{ template "__alertmanagerURL" . }}
{{- end }}
{{ define "opsgenie.default.source" }}{{ template "__alertmanagerURL" . }}{{ end }}

Expand Down Expand Up @@ -73,6 +74,7 @@ Alerts Firing:
Alerts Resolved:
{{ template "__text_alert_list" .Alerts.Resolved }}
{{- end }}
Source: {{ template "__alertmanagerURL" . }}
{{- end }}
{{ define "victorops.default.entity_display_name" }}{{ template "__subject" . }}{{ end }}
{{ define "victorops.default.monitoring_tool" }}{{ template "__alertmanager" . }}{{ end }}
Expand All @@ -87,6 +89,7 @@ Alerts Firing:
Alerts Resolved:
{{ template "__text_alert_list" .Alerts.Resolved }}
{{ end }}
Source: {{ template "__alertmanagerURL" . }}
{{ end }}
{{ define "pushover.default.url" }}{{ template "__alertmanagerURL" . }}{{ end }}

Expand All @@ -100,6 +103,7 @@ Alerts Firing:
Alerts Resolved:
{{ template "__text_alert_list" .Alerts.Resolved }}
{{ end }}
Source: {{ template "__alertmanagerURL" . }}
{{ end }}

{{ define "telegram.default.message" }}
Expand All @@ -111,6 +115,7 @@ Alerts Firing:
Alerts Resolved:
{{ template "__text_alert_list" .Alerts.Resolved }}
{{ end }}
Source: {{ template "__alertmanagerURL" . }}
{{ end }}

{{ define "discord.default.title" }}{{ template "__subject" . }}{{ end }}
Expand All @@ -123,6 +128,7 @@ Alerts Firing:
Alerts Resolved:
{{ template "__text_alert_list" .Alerts.Resolved }}
{{ end }}
Source: {{ template "__alertmanagerURL" . }}
{{ end }}

{{ define "webex.default.message" }}{{ .CommonAnnotations.SortedPairs.Values | join " " }}
Expand All @@ -134,4 +140,5 @@ Alerts Firing:
Alerts Resolved:
{{ template "__text_alert_list" .Alerts.Resolved }}
{{ end }}
{{ end }}
Source: {{ template "__alertmanagerURL" . }}
{{ end }}

0 comments on commit 6d1deeb

Please sign in to comment.