From 050f635b8f97510001793c21b775d77945fa4029 Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Tue, 3 Mar 2026 18:43:15 +0100 Subject: [PATCH] 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; + }; }; }