1 { config, lib, pkgs, options, ... }:
4 cfg = config.services.prometheus.exporters.varnish;
21 Do not exit server on Varnish scrape errors.
24 withGoMetrics = mkOption {
28 Export go runtime and http handler metrics.
35 Enable verbose logging.
42 Enable raw stdout logging without timestamps.
45 varnishStatPath = mkOption {
47 default = "varnishstat";
53 type = types.nullOr types.str;
54 default = config.services.varnish.stateDir;
55 defaultText = lib.literalExpression "config.services.varnish.stateDir";
60 healthPath = mkOption {
61 type = types.nullOr types.str;
64 Path under which to expose healthcheck. Disabled unless configured.
67 telemetryPath = mkOption {
71 Path under which to expose metrics.
76 path = [ config.services.varnish.package ];
78 RestartSec = mkDefault 1;
81 ${pkgs.prometheus-varnish-exporter}/bin/prometheus_varnish_exporter \
82 --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
83 --web.telemetry-path ${cfg.telemetryPath} \
84 --varnishstat-path ${escapeShellArg cfg.varnishStatPath} \
85 ${concatStringsSep " \\\n " (cfg.extraFlags
86 ++ optional (cfg.healthPath != null) "--web.health-path ${cfg.healthPath}"
87 ++ optional (cfg.instance != null) "-n ${escapeShellArg cfg.instance}"
88 ++ optional cfg.noExit "--no-exit"
89 ++ optional cfg.withGoMetrics "--with-go-metrics"
90 ++ optional cfg.verbose "--verbose"
91 ++ optional cfg.raw "--raw")}