@@ -4,6 +4,9 @@ with lib;
44
55let
66 cfg = config.services.prometheus.nodeExporter;
7+ cmdlineArgs = cfg.extraFlags ++ [
8+ "-web.listen-address=${cfg.listenAddress}"
9+ ];
710in {
811 options = {
912 services.prometheus.nodeExporter = {
@@ -33,6 +36,14 @@ in {
3336 Collectors to enable, additionally to the defaults.
3437 '';
3538 };
39+
40+ extraFlags = mkOption {
41+ type = types.listOf types.str;
42+ default = [];
43+ description = ''
44+ Extra commandline options when launching the node exporter.
45+ '';
46+ };
3647 };
3748 };
3849
@@ -40,19 +51,23 @@ in {
4051 networking.firewall.allowedTCPPorts = [ cfg.port ];
4152
4253 systemd.services.prometheus-node-exporter = {
54+ description = "Prometheus exporter for machine metrics";
55+ unitConfig.Documentation = "https://github.com/prometheus/node_exporter";
4356 wantedBy = [ "multi-user.target" ];
4457 after = [ "network.target" ];
4558 script = ''
46− ${pkgs.prometheus-node-exporter.bin}/bin/node_exporter \
59+ exec ${pkgs.prometheus-node-exporter}/bin/node_exporter \
4760 ${optionalString (cfg.enabledCollectors != [])
4861 ''-collectors.enabled ${concatStringsSep "," cfg.enabledCollectors}''} \
49− -web.listen-address ${cfg.listenAddress}:${toString cfg.port}
62+ -web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
63+ ${concatStringsSep " \\\n " cfg.extraFlags}
5064 '';
5165 serviceConfig = {
5266 User = "nobody";
5367 Restart = "always";
5468 PrivateTmp = true;
5569 WorkingDirectory = /tmp;
70+ ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
5671 };
5772 };
5873 };