From 578c5b6583b26bb8d93d08c91be821bbd148a078 Mon Sep 17 00:00:00 2001 From: Nico Felbinger Date: Wed, 22 May 2024 13:24:38 +0200 Subject: [PATCH] prometheus-frr-exporter: init prometheus exporter module --- .../monitoring/prometheus/exporters.nix | 1 + .../monitoring/prometheus/exporters/frr.nix | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 nixos/modules/services/monitoring/prometheus/exporters/frr.nix diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix index 1c2fdbd45d1d8..f805920c5b87a 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters.nix @@ -40,6 +40,7 @@ let "flow" "fritz" "fritzbox" + "frr" "graphite" "idrac" "imap-mailstat" diff --git a/nixos/modules/services/monitoring/prometheus/exporters/frr.nix b/nixos/modules/services/monitoring/prometheus/exporters/frr.nix new file mode 100644 index 0000000000000..f2d3f5a031a68 --- /dev/null +++ b/nixos/modules/services/monitoring/prometheus/exporters/frr.nix @@ -0,0 +1,49 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.services.prometheus.exporters.frr; + inherit (lib) + mkOption + types + concatStringsSep + concatMapStringsSep + ; +in +{ + port = 9342; + extraOpts = { + enabledCollectors = mkOption { + type = types.listOf types.str; + default = [ ]; + example = [ "vrrp" ]; + description = '' + Collectors to enable. The collectors listed here are enabled in addition to the default ones. + ''; + }; + disabledCollectors = mkOption { + type = types.listOf types.str; + default = [ ]; + example = [ "bfd" ]; + description = '' + Collectors to disable which are enabled by default. + ''; + }; + }; + serviceOpts = { + serviceConfig = { + DynamicUser = false; + RuntimeDirectory = "prometheus-frr-exporter"; + ExecStart = '' + ${lib.getExe pkgs.prometheus-frr-exporter} \ + ${concatMapStringsSep " " (x: "--collector." + x) cfg.enabledCollectors} \ + ${concatMapStringsSep " " (x: "--no-collector." + x) cfg.disabledCollectors} \ + --web.listen-address ${cfg.listenAddress}:${toString cfg.port} ${concatStringsSep " " cfg.extraFlags} + ''; + }; + }; +}