From 139fb1816e9044b392df8464b48a626025d9605e Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Sun, 27 Oct 2024 18:35:53 +0530 Subject: [PATCH] rico1: add alertmanager --- hosts/rico1/services/apps/alertmanager.nix | 49 ++++++++++++++++++++++ hosts/rico1/services/apps/blocky.nix | 2 +- hosts/rico1/services/apps/default.nix | 1 + 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 hosts/rico1/services/apps/alertmanager.nix diff --git a/hosts/rico1/services/apps/alertmanager.nix b/hosts/rico1/services/apps/alertmanager.nix new file mode 100644 index 0000000..cbffd4b --- /dev/null +++ b/hosts/rico1/services/apps/alertmanager.nix @@ -0,0 +1,49 @@ +_: +let + inherit (import ../../../shared/caddy-helpers.nix) logFormat; + domainName = "alertmanager.labs.adtya.xyz"; +in +{ + services = { + caddy = { + virtualHosts."${domainName}" = { + logFormat = logFormat "${domainName}"; + extraConfig = '' + reverse_proxy 127.0.0.1:9093 + ''; + }; + }; + prometheus.alertmanager = { + enable = true; + listenAddress = "127.0.0.1"; + port = 9093; + webExternalUrl = "https://${domainName}/"; + configuration = { + route = { + group_by = [ "alertname" ]; + group_wait = "30s"; + group_interval = "5m"; + repeat_interval = "1h"; + receiver = "web.hook"; + }; + receivers = [ + { + name = "web.hook"; + webhook_configs = [ + { url = "http://127.0.0.1:5001/"; } + ]; + } + ]; + inhibit_rules = [ + { + source_match = + { severity = "critical"; }; + target_match = + { severity = "warning"; }; + equal = [ "alertname" "dev" "instance" ]; + } + ]; + }; + }; + }; +} diff --git a/hosts/rico1/services/apps/blocky.nix b/hosts/rico1/services/apps/blocky.nix index b46bf2a..ab28600 100644 --- a/hosts/rico1/services/apps/blocky.nix +++ b/hosts/rico1/services/apps/blocky.nix @@ -74,7 +74,7 @@ in "rico2.labs.adtya.xyz" = "10.10.10.12"; "wynne.labs.adtya.xyz" = "10.10.10.13"; "layne.labs.adtya.xyz" = "10.10.10.14"; - "alertmanager.labs.adtya.xyz" = "10.10.10.10"; + "alertmanager.labs.adtya.xyz" = "10.10.10.11"; "blocky.labs.adtya.xyz" = "10.10.10.11"; "frp.labs.adtya.xyz" = "10.10.10.10"; "grafana.labs.adtya.xyz" = "10.10.10.10"; diff --git a/hosts/rico1/services/apps/default.nix b/hosts/rico1/services/apps/default.nix index b01f012..9d89119 100644 --- a/hosts/rico1/services/apps/default.nix +++ b/hosts/rico1/services/apps/default.nix @@ -3,6 +3,7 @@ _: { ./adtya.xyz.nix ./proofs.nix ./wiki.nix + ./alertmanager.nix ./blocky.nix ../../../shared/prometheus-exporters.nix ../../../shared/promtail.nix