1{ config, lib, pkgs }:
2
3with lib;
4
5let
6 cfg = config.services.prometheus.exporters.node;
7in
8{
9 port = 9100;
10 extraOpts = {
11 enabledCollectors = mkOption {
12 type = types.listOf types.string;
13 default = [];
14 example = ''[ "systemd" ]'';
15 description = ''
16 Collectors to enable. The collectors listed here are enabled in addition to the default ones.
17 '';
18 };
19 disabledCollectors = mkOption {
20 type = types.listOf types.str;
21 default = [];
22 example = ''[ "timex" ]'';
23 description = ''
24 Collectors to disable which are enabled by default.
25 '';
26 };
27 };
28 serviceOpts = {
29 serviceConfig = {
30 RuntimeDirectory = "prometheus-node-exporter";
31 ExecStart = ''
32 ${pkgs.prometheus-node-exporter}/bin/node_exporter \
33 ${concatMapStringsSep " " (x: "--collector." + x) cfg.enabledCollectors} \
34 ${concatMapStringsSep " " (x: "--no-collector." + x) cfg.disabledCollectors} \
35 --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
36 ${concatStringsSep " \\\n " cfg.extraFlags}
37 '';
38 };
39 };
40}