nixos/prometheus-exporters: add zfs-siebenmann exporter

Introduces the NixOS module for the Siebenmann ZFS Prometheus exporter.
Exposes depth, fullPath, and pools options matching the exporter's CLI flags.
This commit is contained in:
xiaodong.jia
2026-04-28 22:07:32 +08:00
parent 33b3eddb2e
commit c81f000203
2 changed files with 65 additions and 0 deletions
@@ -131,6 +131,7 @@ let
"v2ray"
"varnish"
"wireguard"
"zfs-siebenmann"
"zfs"
]
(
@@ -0,0 +1,64 @@
{
config,
lib,
pkgs,
options,
...
}:
let
cfg = config.services.prometheus.exporters.zfs-siebenmann;
inherit (lib)
mkOption
types
concatStringsSep
optionalString
;
in
{
port = 9700;
extraOpts = {
pools = mkOption {
type = with types; listOf str;
default = [ ];
description = ''
Name of the pool(s) to collect, repeat for multiple pools (default: all pools).
'';
};
depth = mkOption {
type = types.int;
default = 1;
description = ''
Depth of the vdev tree to report on.
0 is the pool, 1 is top level vdevs, 2 is devices too.
'';
};
fullPath = mkOption {
type = types.bool;
default = false;
description = ''
Report the full path of disks.
'';
};
};
serviceOpts = {
# needs zpool
path = [ config.boot.zfs.package ];
serviceConfig = {
ExecStart = ''
${pkgs.prometheus-siebenmann-zfs-exporter}/bin/zfs_exporter \
--listen-addr ${cfg.listenAddress}:${toString cfg.port} \
--depth ${toString cfg.depth} \
${optionalString cfg.fullPath "--fullpath"} \
${concatStringsSep " " (map (p: "--pool=${p}") cfg.pools)} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
ProtectClock = false;
PrivateDevices = false;
};
};
}