From 42c35b6333fad97c48762a39c2e079c80bf7833e Mon Sep 17 00:00:00 2001 From: Mel Date: Mon, 23 Dec 2024 02:14:01 +0100 Subject: Scrape metrics from Nginx service access logs Signed-off-by: Mel --- modules/foundation/monitoring/default.nix | 48 ++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 14 deletions(-) (limited to 'modules/foundation/monitoring/default.nix') diff --git a/modules/foundation/monitoring/default.nix b/modules/foundation/monitoring/default.nix index a7bc185..2489948 100644 --- a/modules/foundation/monitoring/default.nix +++ b/modules/foundation/monitoring/default.nix @@ -1,4 +1,9 @@ -{ me, config, lib, ... }: +{ + me, + config, + lib, + ... +}: let inherit (lib) mkOption mkEnableOption types; @@ -10,17 +15,25 @@ let nodeExporterPort = 9001; cadvisorExporterPort = 9002; nginxExporterPort = 9113; + nginxLogExporterPort = 9117; dockerExporterPort = 9323; }; - serverConfiguration = import ./server.nix ({ - hosts = cfg.server.hosts; - victoriaAddress = me.tailscale.ip; - } // ports); + serverConfiguration = import ./server.nix ( + { + hosts = cfg.server.hosts; + victoriaAddress = "${me.tailscale.ip}:${toString ports.victoriaDefaultPort}"; + } + // ports + ); - clientConfiguration = import ./client.nix ({ - listenAddress = me.tailscale.ip; - } // ports); + clientConfiguration = import ./client.nix ( + { + services = cfg.services; + listenAddress = me.tailscale.ip; + } + // ports + ); in { imports = [ ../../../services/monitoring/wrapper.nix ]; @@ -30,12 +43,14 @@ in enable = mkEnableOption "monitoring server"; hosts = mkOption { - type = with types; listOf (submodule { - options = { - name = mkOption { type = str; }; - ip = mkOption { type = str; }; - }; - }); + type = + with types; + listOf (submodule { + options = { + name = mkOption { type = str; }; + ip = mkOption { type = str; }; + }; + }); default = [ ]; }; }; @@ -43,6 +58,11 @@ in client = { enable = mkEnableOption "monitoring client"; }; + + services = mkOption { + type = with types; listOf str; + default = [ ]; + }; }; config = lib.mkMerge [ -- cgit 1.4.1