feat(grafana): added alerts configuration provisioning

This commit is contained in:
ITQ
2025-07-26 05:34:35 +03:00
parent 0db6ed576a
commit 7127227350
3 changed files with 212 additions and 0 deletions
@@ -0,0 +1,54 @@
apiVersion: 1
templates:
- orgId: 1
name: Telegram
template: |
{{ define "telegram.default.message" }} {{ if gt (len .Alerts.Firing) 0 }}
πŸ”₯🚨 *FIRE IN THE HOLE!* 🚨πŸ”₯
We've got *{{ len .Alerts.Firing }} firing alert(s)* that need your immediate attention!
{{ range .Alerts.Firing }}
---
*Alert:* `{{ .Labels.alertname }}`
{{ if .Labels.instance }}*Instance:* `{{ .Labels.instance }}`{{ end }}
*Status:* πŸ”΄ *FIRING* since {{ .StartsAt.Format "2006-01-02 15:04:05 MST" }}
{{ if .Annotations.summary }}*Summary:* {{ .Annotations.summary }}{{ end }}
{{ if .Annotations.description }}*Description:* {{ .Annotations.description }}{{ end }}
*Labels:*
{{ range .Labels.SortedPairs }} β€’ `{{ .Name }}` = `{{ .Value }}`
{{ end }}
{{ if gt (len .Annotations) 0 }}*Annotations:*
{{ range .Annotations.SortedPairs }} β€’ `{{ .Name }}` = `{{ .Value }}`
{{ end }}{{ end }}
{{ if .DashboardURL }}πŸ“Š [View Dashboard]({{ .DashboardURL }})
{{ end }}{{ if .PanelURL }}πŸ“ˆ [View Panel]({{ .PanelURL }})
{{ end }}{{ if .GeneratorURL }}πŸ”— [Alert Source]({{ .GeneratorURL }})
{{ end }}{{ if .SilenceURL }}🀫 [Silence Alert]({{ .SilenceURL }})
{{ end }}--- {{ end }} {{ end }}
{{ if gt (len .Alerts.Resolved) 0 }}
βœ…πŸŸ’ *ALL CLEAR!* πŸŸ’βœ…
Great news! *{{ len .Alerts.Resolved }} alert(s)* have been resolved.
{{ range .Alerts.Resolved }}
---
*Alert:* `{{ .Labels.alertname }}`
{{ if .Labels.instance }}*Instance:* `{{ .Labels.instance }}`{{ end }}
*Status:* βœ… *RESOLVED* at {{ .EndsAt.Format "2006-01-02 15:04:05 MST" }} (was active since {{ .StartsAt.Format "2006-01-02 15:04:05 MST" }})
{{ if .Annotations.summary }}*Summary:* {{ .Annotations.summary }}{{ end }}
{{ if .Annotations.description }}*Description:* {{ .Annotations.description }}{{ end }}
*Labels:*
{{ range .Labels.SortedPairs }} β€’ `{{ .Name }}` = `{{ .Value }}`
{{ end }}
{{ if gt (len .Annotations) 0 }}*Annotations:*
{{ range .Annotations.SortedPairs }} β€’ `{{ .Name }}` = `{{ .Value }}`
{{ end }}{{ end }}
{{ if .DashboardURL }}πŸ“Š [View Dashboard]({{ .DashboardURL }})
{{ end }}{{ if .PanelURL }}πŸ“ˆ [View Panel]({{ .PanelURL }})
{{ end }}{{ if .GeneratorURL }}πŸ”— [Alert Source]({{ .GeneratorURL }}) {{ end }} {{ end }} {{ end }}
{{ if or (gt (len .Alerts.Firing) 0) (gt (len .Alerts.Resolved) 0) }}
πŸ”” *Grafana Alertmanager:* [View All Alerts]({{ template "__alertmanagerURL" . }}) πŸ””
{{ end }}
{{ end }}