From 94b2746018777f6e9313e561e774ee82fd9892d9 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Fri, 2 Apr 2021 17:46:07 +0200 Subject: [PATCH] fuuko/go-neb: Add alertmanager matrix receiver --- README.md | 4 +- .../fuuko/secrets/go-neb-alertmanager.nix | Bin 0 -> 345 bytes machines/fuuko/services/matrix/default.nix | 1 + machines/fuuko/services/matrix/go-neb.nix | 56 ++++++++++++++++++ machines/fuuko/services/prometheus.nix | 11 ++-- 5 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 machines/fuuko/secrets/go-neb-alertmanager.nix create mode 100644 machines/fuuko/services/matrix/go-neb.nix diff --git a/README.md b/README.md index 64405c8..7ad439e 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,9 @@ specific service the machine provides. + `secrets`: Nix expressions that include information that is not meant to be visible to everyone (e.g. accounts, password hashes, private - information etc.) + information etc.) or secrets for services that don’t provide any other + (easy) way of specifying them and whose secrets leaking does not pose a + huge threat * `modules`: Custom modules. Many are activated by default, since I want them on all systems. * `pkgs`: My nixpkgs overlay diff --git a/machines/fuuko/secrets/go-neb-alertmanager.nix b/machines/fuuko/secrets/go-neb-alertmanager.nix new file mode 100644 index 0000000000000000000000000000000000000000..457963dc3e73b7374e4210cbef3670e9151f3081 GIT binary patch literal 345 zcmV-f0jB-{M@dveQdv+`0JbYuT$QU}OvqDhiqt5`lzMIzv5{+SEK%g#+bAOj<3>)* z9HlP2w3ay_nPh>cmsq@^oTh&h)grz~$s6(#RcdYTkru0Qx2N=;4iTQ%u|oi#>X0K4 zvV!)psmrl=7>>dG>Uau9Mzp{ + {{ if eq .Status "firing" -}} + [firing{{ if ne $severity "" }} - {{ $severity }}{{ end }}] + {{- else -}} + [resolved] + {{- end }} + + {{ index .Labels "alertname" }}: {{ index .Annotations "description" }} source
+ {{ end }} + ''; + msg_type = "m.text"; + }; + }; + }; + } + ]; + }; + }; +} diff --git a/machines/fuuko/services/prometheus.nix b/machines/fuuko/services/prometheus.nix index fb0d464..fc9d5a2 100644 --- a/machines/fuuko/services/prometheus.nix +++ b/machines/fuuko/services/prometheus.nix @@ -51,10 +51,13 @@ in receivers = [ { name = "matrix"; - webhook_configs = [ - # FIXME: Add correct URL - { url = "http://matrix-alertmanager:3000/alerts"; } - ]; + webhook_configs = lib.singleton { + url = (lib.elemAt + (lib.filter + ({ ID, ... }: ID == "alertmanager_service") + config.services.go-neb.config.services) + 0).Config.webhook_url; + }; } ]; };