PG Exporter: Containerized Metrics
app/pg_exporter provides a standalone PG Exporter container example for collecting metrics from external PostgreSQL instances. Pigsty’s PGSQL module already manages a native exporter; choose a separate port for this template to avoid conflicts.
Quick Start
The default image is the unpinned pgsty/pg_exporter. .env uses dbuser_dba; prefer dbuser_monitor with monitoring privileges. The default metrics endpoint is http://127.0.0.1:9632/metrics, but the host port mapping is not restricted to loopback.
Ports and Metrics
PG_EXPORTER_PORT controls the published host port. Compose fixes the container target port at 9630. To change the container listening port, explicitly set the binary’s --web.listen-address argument in Compose and update the port mapping; changing .env alone is insufficient.
make view reads the published port from .env, but its path is fixed at /metrics. After changes, inspect mappings with docker compose config and request the actual metrics URL directly.
Only the development template links PG_EXPORTER_LISTEN_ADDRESS (requiring :PORT format) to the Compose port and lets make view select the address and path from the final configuration.
The database account needs the monitoring privileges required by the selected collectors. Replace example passwords before deployment, configure TLS and HBA for the actual network, and restrict access to the metrics port.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)