PG Exporter 1.4 Documentation
Monitor PostgreSQL with 600+ metrics, declarative configuration, and dynamic planning.
Get Started | GitHub | Live Demo
Features
| Feature | Description |
|---|---|
| Comprehensive Metrics | 600+ metrics cover nearly every statistics view in PostgreSQL (10-19+) and pgBouncer (1.8-1.25+) |
| Declarative Collectors | Define each metric in a YAML collector with a SQL query and execution conditions. Add, change, or remove metrics without code changes |
| Dynamic Planning | Select each collector branch for a target by version, primary/replica role, installed extensions, and tags |
| Auto-Discovery | Discover and scrape each database in an instance. The datname label identifies the database |
| Health Check APIs | Use /up, /primary, and /replica as load-balancer probes to route primary/replica traffic |
| Smart Caching | Cache each collector by TTL. Frequent probes and scrapes do not cause an equal number of database queries |
| Snapshot Histograms | Use the HISTOGRAM column type to aggregate SQL snapshots into classic Prometheus histogram distributions |
| Extension Aware | Native support for pg_stat_statements, pg_wait_sampling, citus, and timescaledb |
| Production Ready | Used in production on 12K+ cores for 6+ years |
Version Info
- Current stable release:
v1.4.1 - Default config support: PostgreSQL 10-19+
- Legacy config support: PostgreSQL 9.1-9.6 via the
legacy/config bundle - pgBouncer support: 1.8-1.25+
See Release Notes for the full history.
Design Rationale
pg_exporter uses these principles for production deployments:
- Local connections: if no URL is specified, use
postgresql:///?sslmode=disablefor a database on the same host. - Declarative collection: use YAML collector definitions to control metric behavior with
ttl,timeout,tags, andfatal. - Dynamic planning: select the collector branch at runtime from the server version, role, extensions, and tags.
- Operation during failure: startup is non-blocking by default. HTTP endpoints start even if the database is temporarily unavailable.
- Hot reload: use
POST/GET /reloadorSIGHUPto reload. Non-Windows platforms also supportSIGUSR1. - Separate probes from traffic: health endpoints use cached background probes. Each request does not need a database query.
- Protect management endpoints:
/reload,/explain, and/statexpose runtime and configuration details. In production, protect them with--web.config.fileor keep them internal.
Installation
Select an installation method for your infrastructure:
Quick Start
Follow Getting Started to start PG Exporter:
Documentation
- Getting Started - Quick start guide and basic concepts
- Installation - Installation instructions for all platforms
- Configuration - Configuration reference and examples
- Deployment - Production deployment best practices
- Collectors - Detailed documentation for all metric collectors
Live Demo
Open the PG Exporter demo: https://g.pgsty.com
The demo monitors real PostgreSQL clusters with PG Exporter. It includes:
- Real-time metrics visualization with Grafana
- Multiple PostgreSQL versions and configurations
- Extension-specific metrics and monitoring
- Complete observability stack powered by Pigsty
Community & Support
- GitHub - Source code, issues, and contributions
- Discussions - Ask questions and share experiences
- Pigsty - Complete PostgreSQL Distro with PG Exporter
License
PG Exporter is open-source software licensed under the Apache License 2.0.
Copyright 2018-2026 © Ruohang Feng / [email protected]
Get pg_exporter running and see PostgreSQL metrics in Prometheus within ten minutes
How to download and install the pg_exporter
Production deployment — connection & credentials, systemd / Docker / Kubernetes, auto-discovery and alerting
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)