From 050f635b8f97510001793c21b775d77945fa4029 Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Tue, 3 Mar 2026 18:43:15 +0100 Subject: [PATCH 1/4] comin: Scrape metrics with alloy --- modules/nixos/services/alloy.nix | 14 ++++++++++++++ modules/nixos/services/comin.nix | 17 +++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/modules/nixos/services/alloy.nix b/modules/nixos/services/alloy.nix index 5abfd2c..66341ef 100644 --- a/modules/nixos/services/alloy.nix +++ b/modules/nixos/services/alloy.nix @@ -109,6 +109,20 @@ in } ''; }; + "alloy/comin-metrics.alloy" = { + enable = cfg.collect.metrics.comin; + text = '' + prometheus.scrape "comin" { + targets = [{ + __address__ = "localhost:${toString config.custom.services.comin.metricsPort}", + job = "comin", + instance = constants.hostname, + }] + forward_to = [prometheus.remote_write.default.receiver] + scrape_interval = "30s" + } + ''; + }; }; custom.services.caddy.virtualHosts.${cfg.domain}.port = cfg.port; diff --git a/modules/nixos/services/comin.nix b/modules/nixos/services/comin.nix index d7f495f..d0927b7 100644 --- a/modules/nixos/services/comin.nix +++ b/modules/nixos/services/comin.nix @@ -4,12 +4,21 @@ lib, ... }: +let + cfg = config.custom.services.comin; +in { imports = [ inputs.comin.nixosModules.comin ]; - options.custom.services.comin.enable = lib.mkEnableOption ""; + options.custom.services.comin = { + enable = lib.mkEnableOption ""; + metricsPort = lib.mkOption { + type = lib.types.port; + default = 4243; + }; + }; - config = lib.mkIf config.custom.services.comin.enable { + config = lib.mkIf cfg.enable { services.comin = { enable = true; remotes = lib.singleton { @@ -18,5 +27,9 @@ branches.main.name = "deploy"; }; }; + exporter = { + listen_address = "127.0.0.1"; + inherit (cfg) port; + }; }; } From a351615be5c8c09312d6b283faa3d5f3aa931e3a Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Tue, 3 Mar 2026 18:45:34 +0100 Subject: [PATCH 2/4] comin: Fix port --- modules/nixos/services/comin.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nixos/services/comin.nix b/modules/nixos/services/comin.nix index d0927b7..cf55687 100644 --- a/modules/nixos/services/comin.nix +++ b/modules/nixos/services/comin.nix @@ -29,7 +29,7 @@ in }; exporter = { listen_address = "127.0.0.1"; - inherit (cfg) port; + port = cfg.metricsPort; }; }; } From 5378dd24ae2e61ccfdb00754f2871ca5169c693a Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Tue, 3 Mar 2026 18:46:56 +0100 Subject: [PATCH 3/4] comin: Fix nesting --- modules/nixos/services/comin.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/nixos/services/comin.nix b/modules/nixos/services/comin.nix index cf55687..97190cd 100644 --- a/modules/nixos/services/comin.nix +++ b/modules/nixos/services/comin.nix @@ -26,10 +26,10 @@ in url = "https://github.com/SebastianStork/nixos-config.git"; branches.main.name = "deploy"; }; - }; - exporter = { - listen_address = "127.0.0.1"; - port = cfg.metricsPort; + exporter = { + listen_address = "127.0.0.1"; + port = cfg.metricsPort; + }; }; }; } From 3f882c89c7078216feda585da96b7ee17478b3a7 Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Tue, 3 Mar 2026 18:48:52 +0100 Subject: [PATCH 4/4] alloy: Fix by adding comin option --- modules/nixos/services/alloy.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/nixos/services/alloy.nix b/modules/nixos/services/alloy.nix index 66341ef..ab391b6 100644 --- a/modules/nixos/services/alloy.nix +++ b/modules/nixos/services/alloy.nix @@ -25,6 +25,9 @@ in caddy = lib.mkEnableOption "" // { default = config.services.caddy.enable; }; + comin = lib.mkEnableOption "" // { + default = config.services.comin.enable; + }; }; };