Collecting Data From Pgpool

pgmetrics can collect and report data from Pgpool instances. Pgpool versions v4.0 and later are supported. Pgpool support was added in pgmetrics v1.15.0.

To tell pgmetrics to collect Pgpool metrics, include the --pgpool flag in the command line. You can specify any database to connect to (the postgres database is a good choice). Note that when the --pgpool flag is specified, pgmetrics collects only Pgpool metrics and does not collect any Postgres information or metrics at all.

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

$ pgmetrics -h localhost -p 9999 --pgpool postgres

pgmetrics run at: 18 May 2023 9:30:44 AM (now)

Pgpool Version:   4.4.2 (nurikoboshi)

Pgpool Backends:
    +---------+-----------+------+--------+---------+-----------+------------------------+
    | Node ID |      Host | Port | Status |    Role | LB Weight |     Last Status Change |
    +---------+-----------+------+--------+---------+-----------+------------------------+
    |       0 | localhost | 7000 |     up | primary |       0.5 | 17 May 2023 7:50:40 PM |
    |       1 | localhost | 7001 |     up | standby |       0.5 | 17 May 2023 7:50:40 PM |
    +---------+-----------+------+--------+---------+-----------+------------------------+

Pgpool Backend Statement Counts:
    +--------------------+--------+--------+--------+--------+-----+-------+-------+-------+-------+
    |               Node | SELECT | INSERT | UPDATE | DELETE | DDL | Other | Panic | Fatal | Error |
    +--------------------+--------+--------+--------+--------+-----+-------+-------+-------+-------+
    | 0 (localhost:7000) |     10 |      0 |      0 |      0 |   0 |    20 |     0 |     0 |     0 |
    | 1 (localhost:7001) |     11 |      0 |      0 |      0 |   0 |    11 |     0 |     0 |     0 |
    +--------------------+--------+--------+--------+--------+-----+-------+-------+-------+-------+

The JSON output (use the --format=json option) produces more information, including health checks and in-memory query cache metrics if available:

{
  //... snip ...
  "pgpool": {
    "version": "4.4.2 (nurikoboshi)",
    "backends": [
      {
        "node_id": 0,
        "hostname": "localhost",
        "port": 7000,
        "status": "up",
        "pg_status": "unknown",
        "lb_weight": 0.5,
        "role": "primary",
        "pg_role": "unknown",
        "select_cnt": 11,
        "other_cnt": 21,
        "load_balance_node": true,
        "replication_delay": 0,
        "last_status_change": 1684333240
      },
      {
        "node_id": 1,
        "hostname": "localhost",
        "port": 7001,
        "status": "up",
        "pg_status": "unknown",
        "lb_weight": 0.5,
        "role": "standby",
        "pg_role": "unknown",
        "select_cnt": 11,
        "other_cnt": 11,
        "load_balance_node": false,
        "replication_delay": 0,
        "last_status_change": 1684333240
      }
    ],
    "query_cache": {
      "num_cache_hits": 0,
      "num_selects": 22,
      "cache_hit_ratio": 0,
      "num_hash_entries": 1048576,
      "used_hash_entries": 10,
      "num_cache_entries": 10,
      "used_cache_entries_size": 984,
      "free_cache_entries_size": 67107880,
      "fragment_cache_entries_size": 0
    }
  }
}