6.7. Configuring the Connection Pool #

pgpro-otel-collector supports connection pool configuration for the postgrespro receiver. This feature allows you to limit the maximum number of database connections and optimize connection reuse.

The collector maintains separate connection pools for different purposes: one for the default database (always open to avoid connection management overhead), one for each monitored database, and one for fetcher processes that collect bloat statistics. Each pool can contain up to max_open connections.

Since these pools can be active simultaneously, the total number of connections may reach three times the max_open limit. For example, with max_open set to 5, the collector can establish up to 15 simultaneous connections during peak activity.

Note

If the max_threads value exceeds max_open, the connection pool size is still limited to max_open.

You can monitor the current number of active connections from the collector by running the following SQL query on the monitored database:

SELECT COUNT(*) FROM pg_stat_activity WHERE application_name = 'pgpro-otel-collector';

6.7.1. Parameters #

All parameters have default values that are optimized for typical monitoring workloads. You can adjust them based on your specific database load and the collector performance requirements.

max_idle_time

Maximum time a connection can remain idle.

Default: 10 minutes.

max_lifetime

Maximum connection lifetime, regardless of its usage.

Default: 10 minutes.

connect_timeout

Maximum wait time for connection attempts.

Default: 15 seconds.

max_open

The maximum number of open connections maintained in the pool.

Default: 5.

6.7.2. Configuration Example #

To set up the connection pool, add the following section to your postgrespro receiver configuration:

receivers:
  postgrespro:
    # ... other receiver configuration ...
    connection_pool:
      max_idle_time: 10m
      max_lifetime: 10m
      connect_timeout: 15s
      max_open: 5