Operations 5 min read

Build Real-Time PGPool-II Monitoring with Prometheus & Grafana

This guide walks you through deploying pgpool2_exporter, configuring Prometheus to scrape its metrics, and setting up Grafana dashboards so you can continuously monitor PGPool-II performance and quickly detect issues in a PostgreSQL environment.

Linux Ops Smart Journey
Linux Ops Smart Journey
Linux Ops Smart Journey
Build Real-Time PGPool-II Monitoring with Prometheus & Grafana

In modern database architectures, high availability and performance optimization are essential, and PGPool-II provides connection pooling for PostgreSQL while enhancing scalability and stability. Effective monitoring is equally crucial.

pgpool-exporter Deployment

1. Download the pgpool2_exporter package

<code>$ curl -L -O https://github.com/pgpool/pgpool2_exporter/releases/download/v1.2.2/pgpool2_exporter-1.2.2.linux-amd64.tar.gz</code>

2. Extract the binary

<code>$ temdir=$(mktemp -d)
$ tar xvf pgpool2_exporter-1.2.2.linux-amd64.tar.gz -C ${temdir}

$ sudo cp ${temdir}/pgpool2_exporter-1.2.2.linux-amd64/pgpool2_exporter /usr/local/bin/</code>

3. Create and start the service

<code>$ cat <<'EOF' | sudo tee /usr/lib/systemd/system/pgpool2_exporter.service > /dev/null
[Unit]
Description=pgpool2_exporter
Documentation=https://github.com/pgpool/pgpool2_exporter
Wants=network.service
After=network.service

[Service]
Type=simple
User=postgres
Environment=DATA_SOURCE_USER=postgres
Environment=DATA_SOURCE_PASS=123456
Environment=DATA_SOURCE_URI=172.139.20.188:9999/postgres?sslmode=disable
ExecStart=/usr/local/bin/pgpool2_exporter --web.listen-address=:9719
ExecStop=/bin/kill -s SIGTERM $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

$ sudo systemctl daemon-reload
$ sudo systemctl enable pgpool2_exporter.service --now</code>

4. Clean up temporary files

<code>$ sudo rm -rf ${temdir}</code>

Collect pgpool Metrics

1. Add a Prometheus scrape job for pgpool2

<code>$ kubectl -n kube-system edit cm prometheus
    - job_name: "pgpool2"
      static_configs:
      - targets:
        - "172.139.20.17:9719"</code>

2. Verify that metrics are being collected

<code>$ curl -s $(kubectl -n kube-system get svc prometheus -ojsonpath='{.spec.clusterIP}:{.spec.ports[0].port}')/prometheus/api/v1/query --data-urlencode 'query=up{job="pgpool2"}'
{"status":"success","data":{"resultType":"vector","result":[{"metric":{"__name__":"up","instance":"172.139.20.17:9719","job":"pgpool2"},"value":[1731486018.973,"1"]}]}}</code>

Configure Grafana Dashboard

Add the official pgpool2_exporter dashboard to Grafana: pgpool2.json

Tip: Some adjustments may be needed to achieve the exact appearance shown in the screenshots.

Conclusion

By following these steps, we have built a Prometheus‑and‑Grafana based monitoring system for PGPool‑II, improving database management efficiency and helping prevent potential issues. Keep an eye on evolving monitoring tools to maintain optimal system health.

MonitoringPrometheusPostgreSQLGrafanaExporterPGPool-II
Linux Ops Smart Journey
Written by

Linux Ops Smart Journey

The operations journey never stops—pursuing excellence endlessly.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.