-
-
Save jidckii/5ac5f8f20368b56de72af70222509b7b to your computer and use it in GitHub Desktop.
{{ define "__yucca_text_alert_list" }}{{ range . }} | |
--- | |
πͺͺ <b>{{ .Labels.alertname }}</b> | |
{{- if .Annotations.summary }} | |
π {{ .Annotations.summary }}{{ end }} | |
{{- if .Annotations.description }} | |
π {{ .Annotations.description }}{{ end }} | |
π· Labels: | |
{{ range .Labels.SortedPairs }} <i>{{ .Name }}</i>: <code>{{ .Value }}</code> | |
{{ end }}{{ end }} | |
π <a href="https://yucca.app/">Grafana</a> π <a href="https://yucca.app/">Alertmanager</a> π <a href="https://yucca.app/">Prometheus</a> π | |
{{ end }} | |
{{ define "telegram.yucca.message" }} | |
{{ if gt (len .Alerts.Firing) 0 }} | |
π₯ Alerts Firing π₯ | |
{{ template "__yucca_text_alert_list" .Alerts.Firing }} | |
{{ end }} | |
{{ if gt (len .Alerts.Resolved) 0 }} | |
β Alerts Resolved β | |
{{ template "__yucca_text_alert_list" .Alerts.Resolved }} | |
{{ end }} | |
{{ end }} |
Here is the template for "firing" and "resolved" alerts
`cat ../alertmanager/templates/telegram.tmpl
{{ define "telegram.default.message" }}
{{ if eq .Status "firing" }}
{{ if eq .CommonLabels.severity "critical" }}π΄ Alert: {{ .CommonLabels.alertname }}
{{ else if eq .CommonLabels.severity "warning" }}π Alert: {{ .CommonLabels.alertname }}
{{ else }}βͺοΈ Alert: {{ .CommonLabels.alertname }}
{{ end }}
Status: π₯ FIRING
Severity: {{ if eq .CommonLabels.severity "critical" }}π΄ {{ .CommonLabels.severity | title }}{{ else if eq .CommonLabels.severity "warning" }}π {{ .CommonLabels.severity | title }}{{ else }}βͺοΈ {{ .CommonLabels.severity | title }}{{ end }}
{{ else if eq .Status "resolved" }}
{{ if eq .CommonLabels.severity "critical" }}π’ π TRANSPORT Alert: {{ .CommonLabels.alertname }}
{{ else if eq .CommonLabels.severity "warning" }}π’ π TRANSPORT Alert: {{ .CommonLabels.alertname }}
{{ else }}βͺοΈ Alert: {{ .CommonLabels.alertname }}
{{ end }}
Status: β
RESOLVED
Severity: {{ if eq .CommonLabels.severity "critical" }}π’ {{ .CommonLabels.severity | title }}{{ else if eq .CommonLabels.severity "warning" }}π’ {{ .CommonLabels.severity | title }}{{ else }}βͺοΈ {{ .CommonLabels.severity | title }}{{ end }}
{{ end }}
{{ range .Alerts }}
Instance: {{ .Labels.instance }}
- Title: {{ .Annotations.title }}
- Description: {{ .Annotations.description }}
{{ end }}
{{ end }}`
Example notification:
Firing
π Alert: HighMemoryUsage>90%
Status: π₯ FIRING
Severity: π Warning
Instance: server-1:9100
- Title: WARNING High Memory Usage on server-1:9100
- Description: Memory usage on the instance is 53.67%
Resolved
π’ Alert: HighMemoryUsage>90%
Status: β
RESOLVED
Severity: π’ Warning
Instance: server-1:9100
- Title: WARNING High Memory Usage on server-1:9100
- Description: Memory usage on the instance is 64.59%
Finally, found template that works.