3
0
Fork 0
forked from mirrors/nixpkgs

promeutheus.nginxExporter: add improvements

- use ExecStart and ExecReload
 - add extraFlags
This commit is contained in:
Corbin 2016-11-26 19:56:25 -08:00 committed by Robin Gloster
parent 39e8eaf8b6
commit 363fa27448

View file

@ -33,6 +33,14 @@ in {
Can be enabled with services.nginx.statusPage = true.
'';
};
extraFlags = mkOption {
type = types.listOf types.str;
default = [];
description = ''
Extra commandline options when launching the nginx exporter.
'';
};
};
};
@ -40,18 +48,22 @@ in {
networking.firewall.allowedTCPPorts = [ cfg.port ];
systemd.services.prometheus-nginx-exporter = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" "nginx.service" ];
script = ''
${pkgs.prometheus-nginx-exporter.bin}/bin/nginx_exporter \
-telemetry.address ${cfg.listenAddress}:${toString cfg.port} \
-nginx.scrape_uri ${cfg.scrapeUri}
'';
description = "Prometheus exporter for nginx metrics";
unitConfig.Documentation = "https://github.com/discordianfish/nginx_exporter";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
User = "nobody";
Restart = "always";
PrivateTmp = true;
WorkingDirectory = /tmp;
ExecStart = ''
${pkgs.prometheus-nginx-exporter}/bin/nginx_exporter \
-nginx.scrape_uri '${cfg.scrapeUri}' \
-telemetry.address ${cfg.listenAddress}:${toString cfg.port} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
};
};
};