PgBouncer is an open-source, lightweight, single-binary connection pooler for PostgreSQL. It can pool connections to one or more databases (on possibly different servers) and serve clients over TCP and Unix domain sockets.
Prerequisites
- Create a user in the
PgBouncer /etc/pgbouncer/pgbouncer.ini
file:
stats_users = <Username>
- Add an associated password for
user in the PgBouncer /etc/pgbouncer/userlist.txt
file:
"<Username>" "<PASSWORD>"
Uncomment the
ignore_startup_parameters = extra_float_digits
option in the file/etc/pgbouncer/pgbouncer.ini
such that the connection to pgpooler instance with many modern PostgreSQL clients does not fail.For Virtual machines, install the Linux agent.
Configuring the credentials
Configure the credentials in the directory /opt/opsramp/agent/conf/app.d/creds.yaml
pgbouncer:
- name: pgbouncer
user: <username>
pwd: <Password>
encoding-type: plain
labels:
key1: val1
key2: val2
Configuring the application
Virtual machine
Configure the application in the directory /opt/opsramp/agent/conf/app/discovery/auto-detection.yaml
- name: pgbouncer
instance-checks:
service-check:
- pgbouncer
process-check:
- pgbouncer
port-check:
- 6432
Docker environment
Configure the application in the directory /opt/opsramp/agent/conf/app/discovery/auto-container-detection.yaml
- name: pgbouncer
container-checks:
image-check:
- pgbouncer
port-check:
- 6432
Kubernetes environment
Configure the application in config.yaml
- name: pgbouncer
container-checks:
image-check:
- pgbouncer
port-check:
- 6432
Validate
Go to Resources under the Infrastructure tab to check if your resources are onboarded and the metrics are collected.
Metrics
OpsRamp Metric | Metric Display Name | Unit | Description |
---|---|---|---|
pgbouncer_stats_queries_per_second | Stats Queries Per Second | queries/second | Query rate |
pgbouncer_stats_transactions_per_second | Stats Transactions Per Second | transactions/second | Transaction rate |
pgbouncer_stats_bytes_received_per_second | Stats Bytes Received Per Second | bytes/second | Total network traffic received |
pgbouncer_stats_bytes_sent_per_second | Stats Bytes Sent Per Second | bytes/second | Total network traffic sent |
pgbouncer_stats_total_query_time | Stats Total Query Time | microseconds | Time spent by pgbouncer actively querying PostgreSQL |
pgbouncer_stats_total_transaction_time | Stats Total Transaction Time | microseconds | Time spent by pgbouncer in transactions |
pgbouncer_stats_avg_query_count | Stats Avg Query Count | Queries | Average number of queries per second in last stat period |
pgbouncer_stats_total_wait_time | Stats Total Wait Time | microseconds | Time spent by clients waiting for a server, in microseconds |
pgbouncer_stats_avg_wait_time | Stats Avg Wait Time | microseconds | Time spent by clients waiting for a server, in microseconds (average per second) |
pgbouncer_stats_avg_transaction_count | Stats Avg Transaction Count | Transactions | Average number of transactions per second in last stat period |
pgbouncer_stats_avg_recv | Stats Avg Recv | bytes | Client network traffic received |
pgbouncer_stats_avg_sent | Stats Avg Sent | bytes | Client network traffic sent |
pgbouncer_stats_avg_query_time | Stats Avg Query Time | microseconds | Average query duration |
pgbouncer_stats_avg_transaction_time | Stats Avg Transaction Time | microseconds | Average transaction duration |
pgbouncer_pools_cl_active | Pools Cl Active | Connections | Client connections linked to server connection and able to process queries |
pgbouncer_pools_cl_waiting | Pools Cl Waiting | Connections | Client connections waiting on a server connection |
pgbouncer_pools_sv_active | Pools Sv Active | Connections | Server connections linked to a client connection |
pgbouncer_pools_sv_idle | Pools Sv Idle | Connections | Server connections idle and ready for a client query |
pgbouncer_pools_sv_used | Pools Sv Used | Connections | Server connections idle more than server_check_delay, needing server_check_query |
pgbouncer_pools_sv_tested | Pools Sv Tested | Connections | Server connections currently running either server_reset_query or server_check_query |
pgbouncer_pools_sv_login | Pools Sv Login | Connections | Server connections currently in the process of logging in |
pgbouncer_pools_maxwait | Pools Maxwait | seconds | How long the first (oldest) client in the queue has waited, in seconds |
pgbouncer_pools_maxwait_us | Pools Maxwait Us | microseconds | Microsecond part of the maximum waiting time |
pgbouncer_databases_pool_size | Databases Pool Size | Connections | Maximum number of server connections |
pgbouncer_databases_max_connections | Databases Max Connections | Connections | Maximum number of allowed connections |
pgbouncer_databases_current_connections | Databases Current Connections | Connections | Current number of connections for this database |