Skip to main content

PgBouncer collector

PgBouncer is an open-source connection pooler for PostgreSQL.

This module monitors one or more PgBouncer servers, depending on your configuration.

Executed queries:

  • SHOW VERSION;
  • SHOW CONFIG;
  • SHOW DATABASES;
  • SHOW STATS;
  • SHOW POOLS;

Information about the queries can be found in the PgBouncer Documentation.

Requirements

  • PgBouncer v1.8.0+.
  • A user with stats_users permissions to query your PgBouncer instance.

To create the netdata user:

  • Add netdata user to the pgbouncer.ini file:

    stats_users = netdata
  • Add a password for the netdata user to the userlist.txt file:

    "netdata" "<PASSWORD>"
  • To verify the credentials, run the following command

    psql -h localhost -U netdata -p 6432 pgbouncer -c "SHOW VERSION;" >/dev/null 2>&1 && echo OK || echo FAIL

    When it prompts for a password, enter the password you added to userlist.txt.

Metrics

All metrics have "pgbouncer." prefix.

Labels per scope:

  • global: no labels.
  • database: database, postgres_database.
MetricScopeDimensionsUnits
client_connections_utilizationglobalusedpercentage
db_client_connectionsdatabaseactive, waiting, cancel_reqconnections
db_server_connectionsdatabaseactive, idle, used, tested, loginconnections
db_server_connections_utilizationdatabaseusedpercentage
db_clients_wait_timedatabasetimeseconds
db_client_max_wait_timedatabasetimeseconds
db_transactionsdatabasetransactionstransactions/s
db_transactions_timedatabasetimeseconds
db_transaction_avg_timedatabasetimeseconds
db_queriesdatabasequeriesqueries/s
db_queries_timedatabasetimeseconds
db_query_avg_timedatabasetimeseconds
db_network_iodatabasereceived, sentB/s

Configuration

Edit the go.d/pgbouncer.conf configuration file using edit-config from the Netdata config directory, which is typically at /etc/netdata.

cd /etc/netdata # Replace this path with your Netdata config directory
sudo ./edit-config go.d/pgbouncer.conf

DSN (Data Source Name) may either be in URL format or key=word format. See Connection Strings for details.

jobs:
- name: local
dsn: 'postgres://postgres:[email protected]:6432/pgbouncer'

- name: local
dsn: 'host=/tmp dbname=pgbouncer user=postgres port=6432'

- name: remote
dsn: 'postgres://postgres:[email protected]:6432/pgbouncer'

For all available options see module configuration file.

Troubleshooting

To troubleshoot issues with the pgbouncer collector, run the go.d.plugin with the debug option enabled. The output should give you clues as to why the collector isn't working.

  • Navigate to the plugins.d directory, usually at /usr/libexec/netdata/plugins.d/. If that's not the case on your system, open netdata.conf and look for the plugins setting under [directories].

    cd /usr/libexec/netdata/plugins.d/
  • Switch to the netdata user.

    sudo -u netdata -s
  • Run the go.d.plugin to debug the collector:

    ./go.d.plugin -d -m pgbouncer

Do you have any feedback for this page? If so, you can open a new issue on our netdata/learn repository.