Unquoted null parses as YAML null and breaks routing. Add shared telegram message template.
44 lines
1.4 KiB
Cheetah
44 lines
1.4 KiB
Cheetah
{{- define "telegram.forust.message" -}}
|
||
{{- $statusEmoji := "🚨" -}}
|
||
{{- if ne .Status "firing" -}}{{- $statusEmoji = "✅" -}}{{- end -}}
|
||
{{- $count := len .Alerts.Firing -}}
|
||
{{- if eq .Status "resolved" -}}{{- $count = len .Alerts.Resolved -}}{{- end -}}
|
||
{{ $statusEmoji }} <b>{{ .Status | toUpper }} ({{ $count }})</b>
|
||
{{- range .Alerts }}
|
||
|
||
<b>{{ .Labels.alertname }}</b>
|
||
{{- $sev := .Labels.severity }}
|
||
{{- if eq $sev "critical" }} 🔥 critical
|
||
{{- else if eq $sev "warning" }} ⚠️ warning
|
||
{{- else if eq $sev "info" }} ℹ️ info
|
||
{{- else if $sev }} • {{ $sev }}
|
||
{{- end }}
|
||
{{- if .Annotations.description }}
|
||
|
||
<i>{{ .Annotations.description }}</i>
|
||
{{- end }}
|
||
{{- if .Labels.namespace }}
|
||
📦 Namespace: <code>{{ .Labels.namespace }}</code>
|
||
{{- end }}
|
||
{{- if .Labels.pod }}
|
||
📦 Pod: <code>{{ .Labels.pod }}</code>
|
||
{{- end }}
|
||
{{- if .Labels.container }}
|
||
🐳 Container: <code>{{ .Labels.container }}</code>
|
||
{{- end }}
|
||
{{- if .Labels.node }}
|
||
🖥 Node: <code>{{ .Labels.node }}</code>
|
||
{{- end }}
|
||
{{- if .Labels.instance }}
|
||
🖥 Instance: <code>{{ .Labels.instance }}</code>
|
||
{{- end }}
|
||
{{- if .Labels.job }}
|
||
🔧 Job: <code>{{ .Labels.job }}</code>
|
||
{{- end }}
|
||
{{- if eq .Status "firing" }}
|
||
🕐 Since: <code>{{ .StartsAt | date "2006-01-02 15:04 MST" }}</code>
|
||
{{- else }}
|
||
🕐 Resolved: <code>{{ .EndsAt | date "2006-01-02 15:04 MST" }}</code>
|
||
{{- end }}
|
||
{{- end }}
|
||
{{- end }} |