From 337f17faac0a324f43c5b4a63fec5ae2fae66c54 Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Sun, 27 Oct 2024 18:37:28 +0530 Subject: [PATCH] rico1: add prometheus --- hosts/rico1/services/apps/blocky.nix | 2 +- hosts/rico1/services/apps/default.nix | 1 + hosts/rico1/services/apps/prometheus.nix | 114 +++++++++++++++++++++++ 3 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 hosts/rico1/services/apps/prometheus.nix diff --git a/hosts/rico1/services/apps/blocky.nix b/hosts/rico1/services/apps/blocky.nix index 5b43117..df22fe4 100644 --- a/hosts/rico1/services/apps/blocky.nix +++ b/hosts/rico1/services/apps/blocky.nix @@ -79,7 +79,7 @@ in "frp.labs.adtya.xyz" = "10.10.10.10"; "grafana.labs.adtya.xyz" = "10.10.10.11"; "loki.labs.adtya.xyz" = "10.10.10.11"; - "prometheus.labs.adtya.xyz" = "10.10.10.10"; + "prometheus.labs.adtya.xyz" = "10.10.10.11"; "transmission.labs.adtya.xyz" = "10.10.10.14"; "jellyfin.labs.adtya.xyz" = "10.10.10.14"; "radarr.labs.adtya.xyz" = "10.10.10.14"; diff --git a/hosts/rico1/services/apps/default.nix b/hosts/rico1/services/apps/default.nix index b772e72..9f92847 100644 --- a/hosts/rico1/services/apps/default.nix +++ b/hosts/rico1/services/apps/default.nix @@ -6,6 +6,7 @@ _: { ./alertmanager.nix ./blocky.nix ./grafana.nix + ./prometheus.nix ./loki ../../../shared/prometheus-exporters.nix ../../../shared/promtail.nix diff --git a/hosts/rico1/services/apps/prometheus.nix b/hosts/rico1/services/apps/prometheus.nix new file mode 100644 index 0000000..dcb845a --- /dev/null +++ b/hosts/rico1/services/apps/prometheus.nix @@ -0,0 +1,114 @@ +_: +let + inherit (import ../../../shared/caddy-helpers.nix) logFormat; + domainName = "prometheus.labs.adtya.xyz"; +in +{ + services = { + caddy = { + virtualHosts."${domainName}" = { + logFormat = logFormat domainName; + extraConfig = '' + reverse_proxy 127.0.0.1:9090 + ''; + }; + }; + prometheus = { + enable = true; + listenAddress = "127.0.0.1"; + port = 9090; + globalConfig = { + evaluation_interval = "15s"; + scrape_interval = "15s"; + }; + alertmanagers = [ + { + scheme = "https"; + static_configs = [ + { targets = [ "alertmanager.labs.adtya.xyz" ]; } + ]; + } + ]; + scrapeConfigs = [ + { + job_name = "ntfy"; + scheme = "https"; + metrics_path = "/ntfy-metrics"; + static_configs = [ + { targets = [ "wynne.labs.adtya.xyz" ]; } + ]; + } + { + job_name = "caddy"; + scheme = "https"; + metrics_path = "/caddy-metrics"; + static_configs = [ + { targets = [ "rico0.labs.adtya.xyz" ]; } + { targets = [ "rico1.labs.adtya.xyz" ]; } + { targets = [ "rico2.labs.adtya.xyz" ]; } + { targets = [ "wynne.labs.adtya.xyz" ]; } + { targets = [ "layne.labs.adtya.xyz" ]; } + ]; + } + { + job_name = "postgres"; + scheme = "https"; + metrics_path = "/postgres-metrics"; + static_configs = [ + { targets = [ "wynne.labs.adtya.xyz" ]; } + ]; + } + { + job_name = "systemd"; + scheme = "https"; + metrics_path = "/systemd-metrics"; + static_configs = [ + { targets = [ "rico0.labs.adtya.xyz" ]; } + { targets = [ "rico1.labs.adtya.xyz" ]; } + { targets = [ "rico2.labs.adtya.xyz" ]; } + { targets = [ "wynne.labs.adtya.xyz" ]; } + { targets = [ "layne.labs.adtya.xyz" ]; } + ]; + } + { + job_name = "smartctl"; + scheme = "https"; + metrics_path = "/smartctl-metrics"; + static_configs = [ + { targets = [ "rico0.labs.adtya.xyz" ]; } + { targets = [ "rico1.labs.adtya.xyz" ]; } + { targets = [ "rico2.labs.adtya.xyz" ]; } + { targets = [ "wynne.labs.adtya.xyz" ]; } + { targets = [ "wynne.labs.adtya.xyz" ]; } + { targets = [ "layne.labs.adtya.xyz" ]; } + ]; + } + { + job_name = "node"; + scheme = "https"; + static_configs = [ + { targets = [ "rico0.labs.adtya.xyz" ]; } + { targets = [ "rico1.labs.adtya.xyz" ]; } + { targets = [ "rico2.labs.adtya.xyz" ]; } + { targets = [ "wynne.labs.adtya.xyz" ]; } + { targets = [ "layne.labs.adtya.xyz" ]; } + ]; + } + { + job_name = "frp"; + scheme = "https"; + static_configs = [ + { targets = [ "frp.labs.adtya.xyz" ]; } + ]; + } + { + job_name = "blocky"; + scheme = "https"; + static_configs = [ + { targets = [ "blocky.labs.adtya.xyz" ]; } + ]; + } + ]; + }; + }; +}