From 713c2c5b58593c0396fb92a4e350ecc723c5831e Mon Sep 17 00:00:00 2001 From: Romain Paquet Date: Mon, 25 Aug 2025 07:21:21 +0200 Subject: [PATCH] deploy prometheus clan service --- machines/crocus/configuration.nix | 24 --------------- machines/flake-module.nix | 37 +++++++++++++++++++++++ machines/genepi/monitoring/prometheus.nix | 2 -- machines/genepi/nginx.nix | 2 ++ 4 files changed, 39 insertions(+), 26 deletions(-) diff --git a/machines/crocus/configuration.nix b/machines/crocus/configuration.nix index a0cbb4f..4e3df56 100644 --- a/machines/crocus/configuration.nix +++ b/machines/crocus/configuration.nix @@ -1,6 +1,5 @@ { self, - config, ... }: { @@ -48,29 +47,6 @@ efiInstallAsRemovable = true; }; - services.prometheus = { - enable = true; - port = 9001; - exporters = { - node = { - enable = true; - enabledCollectors = [ "systemd" ]; - port = 9002; - }; - }; - - scrapeConfigs = [ - { - job_name = "crocus"; - static_configs = [ - { - targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ]; - } - ]; - } - ]; - }; - services.nginx = { enable = true; recommendedProxySettings = true; diff --git a/machines/flake-module.nix b/machines/flake-module.nix index 7d46d50..007964b 100644 --- a/machines/flake-module.nix +++ b/machines/flake-module.nix @@ -8,12 +8,14 @@ deploy.targetHost = "root@crocus"; tags = [ "garage" + "server" ]; }; genepi = { deploy.targetHost = "root@genepi"; tags = [ "garage" + "server" ]; }; }; @@ -126,6 +128,41 @@ ]; roles.server.machines = { }; }; + + prometheus = { + module.input = "self"; + module.name = "@rpqt/prometheus"; + + roles.scraper.machines.genepi = { }; + roles.scraper.settings = { + extraScrapeConfigs = [ + { + job_name = "garage"; + static_configs = [ + { + labels.instance = "crocus"; + targets = [ "crocus.home.rpqt.fr:3903" ]; + } + { + labels.instance = "genepi"; + targets = [ "genepi.home.rpqt.fr:3903" ]; + } + ]; + } + ]; + }; + + roles.target.tags.server = { }; + roles.target.settings = { + exporters = { + node = { + enabledCollectors = [ + "systemd" + ]; + }; + }; + }; + }; }; }; } diff --git a/machines/genepi/monitoring/prometheus.nix b/machines/genepi/monitoring/prometheus.nix index 401a422..fcf4d20 100644 --- a/machines/genepi/monitoring/prometheus.nix +++ b/machines/genepi/monitoring/prometheus.nix @@ -58,6 +58,4 @@ in }; }; }; - - clan.core.state.userdata.folders = [ "/var/lib/prometheus2" ]; } diff --git a/machines/genepi/nginx.nix b/machines/genepi/nginx.nix index 410d7db..f05e3a2 100644 --- a/machines/genepi/nginx.nix +++ b/machines/genepi/nginx.nix @@ -4,4 +4,6 @@ recommendedProxySettings = true; recommendedTlsSettings = true; }; + + networking.firewall.interfaces."zts7mq7onf".allowedTCPPorts = [ 443 ]; }