2018-03-09 20:33:09 +00:00
|
|
|
{ config, lib, pkgs }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.prometheus.exporters.nginx;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
port = 9113;
|
|
|
|
extraOpts = {
|
|
|
|
scrapeUri = mkOption {
|
2018-05-01 13:34:28 +01:00
|
|
|
type = types.str;
|
2018-03-09 20:33:09 +00:00
|
|
|
default = "http://localhost/nginx_status";
|
|
|
|
description = ''
|
|
|
|
Address to access the nginx status page.
|
|
|
|
Can be enabled with services.nginx.statusPage = true.
|
|
|
|
'';
|
|
|
|
};
|
2018-05-01 13:34:28 +01:00
|
|
|
telemetryEndpoint = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/metrics";
|
|
|
|
description = ''
|
|
|
|
Path under which to expose metrics.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
insecure = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Ignore server certificate if using https.
|
|
|
|
'';
|
|
|
|
};
|
2018-03-09 20:33:09 +00:00
|
|
|
};
|
|
|
|
serviceOpts = {
|
|
|
|
serviceConfig = {
|
|
|
|
DynamicUser = true;
|
|
|
|
ExecStart = ''
|
|
|
|
${pkgs.prometheus-nginx-exporter}/bin/nginx_exporter \
|
2018-05-01 13:34:28 +01:00
|
|
|
--nginx.scrape_uri '${cfg.scrapeUri}' \
|
|
|
|
--telemetry.address ${cfg.listenAddress}:${toString cfg.port} \
|
|
|
|
--telemetry.endpoint ${cfg.telemetryEndpoint} \
|
2018-05-02 15:03:08 +01:00
|
|
|
--insecure ${toString cfg.insecure} \
|
2018-03-09 20:33:09 +00:00
|
|
|
${concatStringsSep " \\\n " cfg.extraFlags}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|