1 { config, lib, pkgs, options, ... }:
4 cfg = config.services.prometheus.exporters.nginx;
18 scrapeUri = mkOption {
20 default = "http://localhost/nginx_status";
22 Address to access the nginx status page.
23 Can be enabled with services.nginx.statusPage = true.
26 telemetryPath = mkOption {
30 Path under which to expose metrics.
33 sslVerify = mkOption {
37 Whether to perform certificate verification for https.
40 constLabels = mkOption {
41 type = types.listOf types.str;
48 A list of constant labels that will be used in every metric.
52 serviceOpts = mkMerge ([{
53 environment.CONST_LABELS = concatStringsSep "," cfg.constLabels;
56 ${pkgs.prometheus-nginx-exporter}/bin/nginx-prometheus-exporter \
57 --nginx.scrape-uri='${cfg.scrapeUri}' \
58 --${lib.optionalString (!cfg.sslVerify) "no-"}nginx.ssl-verify \
59 --web.listen-address=${cfg.listenAddress}:${toString cfg.port} \
60 --web.telemetry-path=${cfg.telemetryPath} \
61 ${concatStringsSep " \\\n " cfg.extraFlags}
64 }] ++ [(mkIf config.services.nginx.enable {
65 after = [ "nginx.service" ];
66 requires = [ "nginx.service" ];
69 (mkRenamedOptionModule [ "telemetryEndpoint" ] [ "telemetryPath" ])
70 (mkRemovedOptionModule [ "insecure" ] ''
71 This option was replaced by 'prometheus.exporters.nginx.sslVerify'.
73 ({ options.warnings = options.warnings; options.assertions = options.assertions; })