From 50cd2305c4a696c94fc78e2fd134aaaf0df688f5 Mon Sep 17 00:00:00 2001 From: fi Date: Sat, 10 May 2025 00:10:09 +0200 Subject: [PATCH] Enable prometheus alertmanager --- config/hosts/metrics/nginx.nix | 19 +++++++++++++++++++ config/hosts/metrics/prometheus.nix | 6 ++++++ .../virtualHosts/acme-challenge.nix | 1 + 3 files changed, 26 insertions(+) diff --git a/config/hosts/metrics/nginx.nix b/config/hosts/metrics/nginx.nix index 9e31454..aefb0b5 100644 --- a/config/hosts/metrics/nginx.nix +++ b/config/hosts/metrics/nginx.nix @@ -22,6 +22,25 @@ proxyWebsockets = true; }; }; + "alertmanager.grzb.de"= { + forceSSL = true; + enableACME = true; + listen = [ + { + addr = "0.0.0.0"; + port = 80; + } + { + addr = "0.0.0.0"; + port = 443; + ssl = true; + } + ]; + locations."/" = { + proxyPass = "http://${config.services.prometheus.alertmanager.listenAddress}:${builtins.toString config.services.prometheus.alertmanager.port}"; + proxyWebsockets = true; + }; + }; }; }; } diff --git a/config/hosts/metrics/prometheus.nix b/config/hosts/metrics/prometheus.nix index c4b45b1..b45eb94 100644 --- a/config/hosts/metrics/prometheus.nix +++ b/config/hosts/metrics/prometheus.nix @@ -2,6 +2,7 @@ { services.prometheus = { enable = true; + retentionTime = "90d"; scrapeConfigs = [ { job_name = "node"; @@ -15,5 +16,10 @@ }) (builtins.attrNames hosts); } ]; + alertmanager = { + enable = true; + listenAddress = "localhost"; + webExternalUrl = "https://alertmanager.grzb.de"; + }; }; } diff --git a/config/hosts/web-public-2/virtualHosts/acme-challenge.nix b/config/hosts/web-public-2/virtualHosts/acme-challenge.nix index 8f38379..38d2804 100644 --- a/config/hosts/web-public-2/virtualHosts/acme-challenge.nix +++ b/config/hosts/web-public-2/virtualHosts/acme-challenge.nix @@ -1,6 +1,7 @@ { ... }: let acmeDomainMap = { + "alertmanager.grzb.de" = "metrics.vs.grzb.de"; "jellyfin.grzb.de" = "jellyfin.vs.grzb.de"; "mail-1.grzb.de" = "mail-1.vs.grzb.de"; "mas.nekover.se" = "matrix.vs.grzb.de";