1{ config, lib, pkgs }: 2 3with lib; 4 5let 6 cfg = config.services.prometheus.exporters.nginx; 7in 8{ 9 port = 9113; 10 extraOpts = { 11 scrapeUri = mkOption { 12 type = types.str; 13 default = "http://localhost/nginx_status"; 14 description = '' 15 Address to access the nginx status page. 16 Can be enabled with services.nginx.statusPage = true. 17 ''; 18 }; 19 telemetryEndpoint = mkOption { 20 type = types.str; 21 default = "/metrics"; 22 description = '' 23 Path under which to expose metrics. 24 ''; 25 }; 26 insecure = mkOption { 27 type = types.bool; 28 default = true; 29 description = '' 30 Ignore server certificate if using https. 31 ''; 32 }; 33 }; 34 serviceOpts = { 35 serviceConfig = { 36 DynamicUser = true; 37 ExecStart = '' 38 ${pkgs.prometheus-nginx-exporter}/bin/nginx_exporter \ 39 --nginx.scrape_uri '${cfg.scrapeUri}' \ 40 --telemetry.address ${cfg.listenAddress}:${toString cfg.port} \ 41 --telemetry.endpoint ${cfg.telemetryEndpoint} \ 42 --insecure ${toString cfg.insecure} \ 43 ${concatStringsSep " \\\n " cfg.extraFlags} 44 ''; 45 }; 46 }; 47}