summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--nixos/modules/services/monitoring/prometheus/node-exporter.nix19
1 files changed, 17 insertions, 2 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/node-exporter.nix b/nixos/modules/services/monitoring/prometheus/node-exporter.nix
index 6750d4c75070..02aedb53564d 100644
--- a/nixos/modules/services/monitoring/prometheus/node-exporter.nix
+++ b/nixos/modules/services/monitoring/prometheus/node-exporter.nix
@@ -4,6 +4,9 @@ with lib;
 
 let
   cfg = config.services.prometheus.nodeExporter;
+  cmdlineArgs = cfg.extraFlags ++ [
+    "-web.listen-address=${cfg.listenAddress}"
+  ];
 in {
   options = {
     services.prometheus.nodeExporter = {
@@ -33,6 +36,14 @@ in {
           Collectors to enable, additionally to the defaults.
         '';
       };
+
+      extraFlags = mkOption {
+        type = types.listOf types.str;
+        default = [];
+        description = ''
+          Extra commandline options when launching the node exporter.
+        '';
+      };
     };
   };
 
@@ -40,19 +51,23 @@ in {
     networking.firewall.allowedTCPPorts = [ cfg.port ];
 
     systemd.services.prometheus-node-exporter = {
+      description = "Prometheus exporter for machine metrics";
+      unitConfig.Documentation = "https://github.com/prometheus/node_exporter";
       wantedBy = [ "multi-user.target" ];
       after    = [ "network.target" ];
       script = ''
-        ${pkgs.prometheus-node-exporter.bin}/bin/node_exporter \
+        exec ${pkgs.prometheus-node-exporter}/bin/node_exporter \
           ${optionalString (cfg.enabledCollectors != [])
             ''-collectors.enabled ${concatStringsSep "," cfg.enabledCollectors}''} \
-          -web.listen-address ${cfg.listenAddress}:${toString cfg.port}
+          -web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
+          ${concatStringsSep " \\\n  " cfg.extraFlags}
       '';
       serviceConfig = {
         User = "nobody";
         Restart  = "always";
         PrivateTmp = true;
         WorkingDirectory = /tmp;
+        ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
       };
     };
   };