1 { config, lib, pkgs, options, ... }:
4 cfg = config.services.prometheus.exporters.node;
13 collectorIsEnabled = final: any (collector: (final == collector)) cfg.enabledCollectors;
14 collectorIsDisabled = final: any (collector: (final == collector)) cfg.disabledCollectors;
19 enabledCollectors = mkOption {
20 type = types.listOf types.str;
22 example = [ "systemd" ];
24 Collectors to enable. The collectors listed here are enabled in addition to the default ones.
27 disabledCollectors = mkOption {
28 type = types.listOf types.str;
30 example = [ "timex" ];
32 Collectors to disable which are enabled by default.
39 RuntimeDirectory = "prometheus-node-exporter";
41 ${pkgs.prometheus-node-exporter}/bin/node_exporter \
42 ${concatMapStringsSep " " (x: "--collector." + x) cfg.enabledCollectors} \
43 ${concatMapStringsSep " " (x: "--no-collector." + x) cfg.disabledCollectors} \
44 --web.listen-address ${cfg.listenAddress}:${toString cfg.port} ${concatStringsSep " " cfg.extraFlags}
46 RestrictAddressFamilies = optionals (collectorIsEnabled "logind" || collectorIsEnabled "systemd") [
47 # needs access to dbus via unix sockets (logind/systemd)
49 ] ++ optionals (collectorIsEnabled "network_route" || collectorIsEnabled "wifi" || ! collectorIsDisabled "netdev") [
50 # needs netlink sockets for wireless collector
53 # The timex collector needs to access clock APIs
54 ProtectClock = collectorIsDisabled "timex";
55 # Allow space monitoring under /home