Skip to content

Instantly share code, notes, and snippets.

@lephleg
Last active May 22, 2024 13:03
Show Gist options
  • Save lephleg/fa07777eb8147edae1d41b0d87e8a87e to your computer and use it in GitHub Desktop.
Save lephleg/fa07777eb8147edae1d41b0d87e8a87e to your computer and use it in GitHub Desktop.
Ads A8C Grafana Template
{{ define "ads.slack.title" }}
{{ if gt (len .Alerts.Firing) 0 }}
🔥 {{ len .Alerts.Firing }} alert(s) firing
{{ end }}
{{ if gt (len .Alerts.Resolved) 0 }}
✅ {{ len .Alerts.Resolved }} alert(s) resolved
{{ end }}
{{ end }}
{{ define "ads.slack.alert_links" }}
{{ if gt (len .DashboardURL) 0 }}<{{ .DashboardURL }}|Dashboard> | {{ end }}{{ if gt (len .PanelURL) 0 }}<{{ .PanelURL }}|Panel> | {{ end }}{{ if gt (len .GeneratorURL) 0 }}<{{ .GeneratorURL }}|Alert> | {{ end }}{{ if gt (len .SilenceURL) 0 }}<{{ .SilenceURL }}|Silence>{{ end }}
{{ end }}
{{ define "ads.slack.alert_firing" }}
*{{ .Annotations.summary }}*
{{ .Annotations.description }}
{{ template "ads.slack.alert_links" .}}
{{ end }}
{{ define "ads.slack.alert_resolved" }}
*{{ .Annotations.summary }}*
{{ template "ads.slack.alert_links" .}}
{{ end }}
{{ define "ads.slack.message" }}
{{ if gt (len .Alerts.Firing) 0 }}
{{ range .Alerts.Firing }} {{ template "ads.slack.alert_firing" .}} {{ end }}
{{ end }}
{{ if gt (len .Alerts.Resolved) 0 }}
{{ range .Alerts.Resolved }} {{ template "ads.slack.alert_resolved" .}} {{ end }}
{{ end }}
{{ end }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment