From 35d3347db42fb06d1e445a7ff3ec7e5b43a813d5 Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Sun, 18 Aug 2024 09:57:42 +0300 Subject: [PATCH] wip: continue prometheus role --- roles/prometheus.nix | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/roles/prometheus.nix b/roles/prometheus.nix index a2c4797..c8f1f5a 100644 --- a/roles/prometheus.nix +++ b/roles/prometheus.nix @@ -14,11 +14,41 @@ in { default = false; description = "Wheter to open firewall ports for enabled exporters"; }; - node.enable = lib.mkEnableOption "node exporter"; - systemd.enable = lib.mkEnableOption "systemd exporter"; + node = lib.mkOption { + type = lib.types.submodule { + options = { + enable = lib.mkEnableOption "node exporter"; + port = lib.mkOption { + type = lib.types.port; + }; + extraFlags = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = []; + }; + }; + }; + }; + systemd = lib.mkOption { + type = lib.types.submodule { + options = { + enable = lib.mkEnableOption "systemd exporter"; + }; + }; + }; }; }; - default = {}; + }; + }; + + config = { + services.prometheus.exporters = { + node = lib.mkIf cfg.exporters.node.enable { + port = cfg.exporters.node.port; + extraFlags = cfg.exporters.node.extraFlags; + }; + systemd = lib.mkIf cfg.exporters.systemd.enable { + port = cfg.exporters.systemd.port; + }; }; }; } -- 2.44.1