From 1394ae1bd4bc3dcfb77b0daee996e75f8092fc5b Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 14 Sep 2020 16:56:30 +0200 Subject: shack/prometheus: add custom shack template --- .../shack/prometheus/alertmanager-telegram.nix | 4 ++-- .../2configs/shack/prometheus/templates/shack.tmpl | 25 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 krebs/2configs/shack/prometheus/templates/shack.tmpl (limited to 'krebs/2configs/shack') diff --git a/krebs/2configs/shack/prometheus/alertmanager-telegram.nix b/krebs/2configs/shack/prometheus/alertmanager-telegram.nix index 9d0ef45e8..2df63e520 100644 --- a/krebs/2configs/shack/prometheus/alertmanager-telegram.nix +++ b/krebs/2configs/shack/prometheus/alertmanager-telegram.nix @@ -8,10 +8,10 @@ DynamicUser = true; StateDirectory = "alertbot"; ExecStart = ''${pkgs.alertmanager-bot-telegram}/bin/alertmanager-bot \ - --alertmanager.url=http://alert.prometheus.shack --log.level=info \ + --alertmanager.url=http://alert.prometheus.shack --log.level=debug \ --store=bolt --bolt.path=/var/lib/alertbot/bot.db \ --listen.addr="0.0.0.0:16320" \ - --template.paths=${pkgs.alertmanager-bot-telegram}/templates/default.tmpl''; + --template.paths=${./templates}/shack.tmpl''; }; }; } diff --git a/krebs/2configs/shack/prometheus/templates/shack.tmpl b/krebs/2configs/shack/prometheus/templates/shack.tmpl new file mode 100644 index 000000000..9295f019f --- /dev/null +++ b/krebs/2configs/shack/prometheus/templates/shack.tmpl @@ -0,0 +1,25 @@ +{{ define "telegram.default" }} +{{range .Alerts -}} +{{ $severity := index .Labels "severity" }} +{{ $desc := "No Description" }} +{{ if eq .Status "firing" }} + {{ $desc = index .Annotations "description" }} + {{- if eq $severity "critical" -}} + [CRITICAL] + {{- else if eq $severity "warning" -}} + [WARNING] + {{- else -}} + [{{ $severity }}] + {{- end -}} +{{ else -}} + {{ $desc = "The issue has been resolved" }} + [RESOLVED] +{{- end }} {{ index .Labels "alertname"}}: {{ index .Annotations "summary"}} + +{{ $desc }} + +Alert Links: +* Grafana +* Source +{{end -}} +{{end}} -- cgit v1.2.3