1{ config, lib, pkgs }: 2 3with lib; 4 5let 6 cfg = config.services.prometheus.exporters.varnish; 7in 8{ 9 port = 9131; 10 extraOpts = { 11 noExit = mkOption { 12 type = types.bool; 13 default = false; 14 description = '' 15 Do not exit server on Varnish scrape errors. 16 ''; 17 }; 18 withGoMetrics = mkOption { 19 type = types.bool; 20 default = false; 21 description = '' 22 Export go runtime and http handler metrics. 23 ''; 24 }; 25 verbose = mkOption { 26 type = types.bool; 27 default = false; 28 description = '' 29 Enable verbose logging. 30 ''; 31 }; 32 raw = mkOption { 33 type = types.bool; 34 default = false; 35 description = '' 36 Enable raw stdout logging without timestamps. 37 ''; 38 }; 39 varnishStatPath = mkOption { 40 type = types.str; 41 default = "varnishstat"; 42 description = '' 43 Path to varnishstat. 44 ''; 45 }; 46 instance = mkOption { 47 type = types.nullOr types.str; 48 default = null; 49 description = '' 50 varnishstat -n value. 51 ''; 52 }; 53 healthPath = mkOption { 54 type = types.nullOr types.str; 55 default = null; 56 description = '' 57 Path under which to expose healthcheck. Disabled unless configured. 58 ''; 59 }; 60 telemetryPath = mkOption { 61 type = types.str; 62 default = "/metrics"; 63 description = '' 64 Path under which to expose metrics. 65 ''; 66 }; 67 }; 68 serviceOpts = { 69 path = [ pkgs.varnish ]; 70 serviceConfig = { 71 DynamicUser = true; 72 ExecStart = '' 73 ${pkgs.prometheus-varnish-exporter}/bin/prometheus_varnish_exporter \ 74 --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \ 75 --web.telemetry-path ${cfg.telemetryPath} \ 76 --varnishstat-path ${cfg.varnishStatPath} \ 77 ${concatStringsSep " \\\n " (cfg.extraFlags 78 ++ optional (cfg.healthPath != null) "--web.health-path ${cfg.healthPath}" 79 ++ optional (cfg.instance != null) "-n ${cfg.instance}" 80 ++ optional cfg.noExit "--no-exit" 81 ++ optional cfg.withGoMetrics "--with-go-metrics" 82 ++ optional cfg.verbose "--verbose" 83 ++ optional cfg.raw "--raw")} 84 ''; 85 }; 86 }; 87}