forked from mirrors/nixpkgs
Merge branch 'prometheus-node-exporter' of https://github.com/teh/nixpkgs into prometheus-nixos-exporter
This commit is contained in:
commit
55b8430f6f
|
@ -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";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue