Collecting Data From PgBouncer

pgmetrics can collect and report data from PgBouncer instances.

PgBouncer exposes a virtual admin database called pgbouncer. If you let pgmetrics connect to this database, it will collect and report PgBouncer metrics instead of the regular PostgreSQL metrics.

pgmetrics can report the data as both text and JSON. Here is how the text output looks like:

$ pgmetrics -h localhost -p 6432 pgbouncer

pgmetrics run at: 27 May 2019 11:23:43 AM (now)

PgBouncer Databases:
    +-----------+--------------------------+---------+-----------+---------+--------+----------+--------------+
    |  Database |                  Maps To | Paused? | Disabled? | Clients | Xacts* | Queries* | Client Wait* |
    +-----------+--------------------------+---------+-----------+---------+--------+----------+--------------+
    |       db1 |       localhost:5432/db1 |      no |        no |       8 |  62480 |   437116 |      25.143s |
    |      fdb1 | user1@localhost:5432/db1 |      no |        no |       0 |      0 |        0 |           0s |
    | pgbouncer |               (internal) |      no |        no |       0 |      9 |        9 |           0s |
    +-----------+--------------------------+---------+-----------+---------+--------+----------+--------------+
                                                                 * = cumulative values since start of PgBouncer

PgBouncer Pools:
    +-----------+-----------+-----------+-----------------+------------------------+-----------+
    |      User |  Database |      Mode |    Client Conns |           Server Conns |  Max Wait |
    +-----------+-----------+-----------+-----------------+------------------------+-----------+
    |     user1 |       db1 |   session | 8 actv, 33 wtng | 8 actv, 0 idle, 0 othr | 1m13.766s |
    | pgbouncer | pgbouncer | statement |  1 actv, 0 wtng | 0 actv, 0 idle, 0 othr |        0s |
    +-----------+-----------+-----------+-----------------+------------------------+-----------+

Current Connections:
    Clients: 9 active, 33 waiting, 0 idle, 0 used
    Servers: 8 active, 0 idle, 0 used
    Client Wait Times: max 1m13.769s, avg 1m11.794s