Commit 6008ed89 authored by Ivan Trubach's avatar Ivan Trubach
Browse files

nixos/prometheus.exporters.pgbouncer: do not assume that pgbouncer runs on localhost

PgBouncer instance running on localhost may not be the on being
monitored in connectionString. Remove checks that forbid valid
configuration from being used and instead document requirements for
PgBouncer configuration when used with the exporter.
parent bfb9d182
Loading
Loading
Loading
Loading
+0 −17
Original line number Diff line number Diff line
@@ -367,18 +367,6 @@ in
        message = ''
          PgBouncer exporter needs either connectionStringFile or connectionString configured"
        '';
    } {
      assertion = cfg.pgbouncer.enable -> (
        config.services.pgbouncer.ignoreStartupParameters != null && builtins.match ".*extra_float_digits.*" config.services.pgbouncer.ignoreStartupParameters != null
        );
        message = ''
          Prometheus PgBouncer exporter requires including `extra_float_digits` in services.pgbouncer.ignoreStartupParameters

          Example:
          services.pgbouncer.ignoreStartupParameters = extra_float_digits;

          See https://github.com/prometheus-community/pgbouncer_exporter#pgbouncer-configuration
        '';
    } {
      assertion = cfg.sql.enable -> (
        (cfg.sql.configFile == null) != (cfg.sql.configuration == null)
@@ -437,11 +425,6 @@ in
          config.services.prometheus.exporters.pgbouncer.connectionString is insecure. Use connectionStringFile instead.
        ''
      )
      (mkIf
        (cfg.pgbouncer.enable && config.services.pgbouncer.authType != "any") ''
          Admin user (with password or passwordless) MUST exist in the services.pgbouncer.authFile if authType other than any is used.
        ''
      )
    ] ++ config.services.prometheus.exporters.warnings;
  }]  ++ [(mkIf config.services.prometheus.exporters.rtl_433.enable {
    hardware.rtl-sdr.enable = mkDefault true;
+8 −4
Original line number Diff line number Diff line
@@ -31,8 +31,10 @@ in

        NOTE: You MUST keep pgbouncer as database name (special internal db)!!!

        NOTE: Admin user (with password or passwordless) MUST exist
        in the services.pgbouncer.authFile if authType other than any is used.
        NOTE: ignore_startup_parameters MUST contain "extra_float_digits".

        NOTE: Admin user (with password or passwordless) MUST exist in the
        auth_file if auth_type other than "any" is used.

        WARNING: this secret is stored in the world-readable Nix store!
        Use {option}`connectionStringFile` instead.
@@ -49,8 +51,10 @@ in

        NOTE: You MUST keep pgbouncer as database name (special internal db)!!!

        NOTE: Admin user (with password or passwordless) MUST exist
        in the services.pgbouncer.authFile if authType other than any is used.
        NOTE: ignore_startup_parameters MUST contain "extra_float_digits".

        NOTE: Admin user (with password or passwordless) MUST exist in the
        auth_file if auth_type other than "any" is used.

        {option}`connectionStringFile` takes precedence over {option}`connectionString`
      '';
+17 −6
Original line number Diff line number Diff line
@@ -1001,13 +1001,24 @@ let
      metricProvider = {
        services.postgresql.enable = true;
        services.pgbouncer = {
          # https://github.com/prometheus-community/pgbouncer_exporter#pgbouncer-configuration
          ignoreStartupParameters = "extra_float_digits";
          enable = true;
          listenAddress = "*";
          databases = { postgres = "host=/run/postgresql/ port=5432 auth_user=postgres dbname=postgres"; };
          authType = "any";
          maxClientConn = 99;
          settings = {
            pgbouncer = {
              listen_addr = "*";
              auth_type = "any";
              max_client_conn = 99;
              # https://github.com/prometheus-community/pgbouncer_exporter#pgbouncer-configuration
              ignore_startup_parameters = "extra_float_digits";
            };
            databases = {
              postgres = concatStringsSep " " [
                "host=/run/postgresql"
                "port=5432"
                "auth_user=postgres"
                "dbname=postgres"
              ];
            };
          };
        };
      };
      exporterTest = ''