10 cfg = config.services.prometheus.exporters.pgbouncer;
24 package = mkPackageOption pkgs "prometheus-pgbouncer-exporter" { };
26 telemetryPath = mkOption {
30 Path under which to expose metrics.
34 connectionString = mkOption {
35 type = types.nullOr types.str;
37 example = "postgres://admin:@localhost:6432/pgbouncer?sslmode=require";
39 Connection string for accessing pgBouncer.
41 NOTE: You MUST keep pgbouncer as database name (special internal db)!!!
43 NOTE: ignore_startup_parameters MUST contain "extra_float_digits".
45 NOTE: Admin user (with password or passwordless) MUST exist in the
46 auth_file if auth_type other than "any" is used.
48 WARNING: this secret is stored in the world-readable Nix store!
49 Use [](#opt-services.prometheus.exporters.pgbouncer.connectionEnvFile) if the
50 URL contains a secret.
54 connectionEnvFile = mkOption {
55 type = types.nullOr types.str;
58 File that must contain the environment variable
59 `PGBOUNCER_EXPORTER_CONNECTION_STRING` which is set to the connection
60 string used by pgbouncer. I.e. the format is supposed to look like this:
63 PGBOUNCER_EXPORTER_CONNECTION_STRING="postgres://admin@localhost:6432/pgbouncer?sslmode=require"
66 NOTE: You MUST keep pgbouncer as database name (special internal db)!
67 NOTE: `services.pgbouncer.settings.pgbouncer.ignore_startup_parameters`
68 MUST contain "extra_float_digits".
70 Mutually exclusive with [](#opt-services.prometheus.exporters.pgbouncer.connectionString).
75 type = types.nullOr types.str;
78 Path to PgBouncer pid file.
80 If provided, the standard process metrics get exported for the PgBouncer
81 process, prefixed with 'pgbouncer_process_...'. The pgbouncer_process exporter
82 needs to have read access to files owned by the PgBouncer process. Depends on
83 the availability of /proc.
85 https://prometheus.io/docs/instrumenting/writing_clientlibs/#process-metrics.
90 webSystemdSocket = mkOption {
94 Use systemd socket activation listeners instead of port listeners (Linux only).
107 Only log messages with the given severity or above.
111 logFormat = mkOption {
118 Output format of log messages. One of: [logfmt, json]
122 webConfigFile = mkOption {
123 type = types.nullOr types.path;
126 Path to configuration file that can enable TLS or authentication.
130 extraFlags = mkOption {
131 type = types.listOf types.str;
134 Extra commandline options when launching Prometheus.
141 after = [ "pgbouncer.service" ];
142 script = concatStringsSep " " (
144 "exec -- ${escapeShellArg (getExe cfg.package)}"
145 "--web.listen-address ${cfg.listenAddress}:${toString cfg.port}"
147 ++ optionals (cfg.connectionString != null) [
148 "--pgBouncer.connectionString ${escapeShellArg cfg.connectionString}"
150 ++ optionals (cfg.telemetryPath != null) [
151 "--web.telemetry-path ${escapeShellArg cfg.telemetryPath}"
153 ++ optionals (cfg.pidFile != null) [
154 "--pgBouncer.pid-file ${escapeShellArg cfg.pidFile}"
156 ++ optionals (cfg.logLevel != null) [
157 "--log.level ${escapeShellArg cfg.logLevel}"
159 ++ optionals (cfg.logFormat != null) [
160 "--log.format ${escapeShellArg cfg.logFormat}"
162 ++ optionals (cfg.webSystemdSocket != false) [
163 "--web.systemd-socket ${escapeShellArg cfg.webSystemdSocket}"
165 ++ optionals (cfg.webConfigFile != null) [
166 "--web.config.file ${escapeShellArg cfg.webConfigFile}"
171 serviceConfig.RestrictAddressFamilies = [
176 serviceConfig.EnvironmentFile = lib.mkIf (cfg.connectionEnvFile != null) [
177 cfg.connectionEnvFile
182 (lib.mkRemovedOptionModule [ "connectionStringFile" ] ''
183 As replacement, the option `services.prometheus.exporters.pgbouncer.connectionEnvFile`
184 has been added. In contrast to `connectionStringFile` it must be an environment file
185 with the connection string being set to `PGBOUNCER_EXPORTER_CONNECTION_STRING`.
187 The change was necessary since the former option wrote the contents of the file
188 into the cmdline of the exporter making the connection string effectively
192 options.warnings = options.warnings;
193 options.assertions = options.assertions;