Advanced PostgreSQL & pgBouncer
Metrics Exporter for Prometheus
The ultimate monitoring experience for PostgreSQL with 600+ metrics,
declarative configuration, and dynamic planning capabilities
Comprehensive Metrics
Monitor PostgreSQL (10-18+) and pgBouncer (1.8-1.24+) with 600+ metrics and ~3K time series per instance
Declarative Configuration
Define custom metrics through YAML configs with fine-grained control over timeout, caching, and skip conditions
Custom Collectors
Define your own metrics with declarative YAML configuration and dynamic query planning
Auto-Discovery
Automatically discover and monitor multiple databases within a PostgreSQL instance
Dynamic Planning
Automatically adapt metric collection based on PostgreSQL version, extensions, and server characteristics
Production Ready
Battle-tested in real-world environments across 12K+ cores for 6+ years with enterprise reliability
Health Check APIs
Comprehensive HTTP endpoints for service health and traffic routing with primary/replica detection
Smart Caching
Built-in caching mechanism with configurable TTL to reduce database load and improve performance
Extension Aware
Native support for TimescaleDB, Citus, pg_stat_statements, pg_wait_sampling and automatic detection
Installation
PG Exporter provides multiple install methods to fit your infrastructure:
docker run -d --name pg_exporter -p 9630:9630 -e PG_EXPORTER_URL="postgres://user:pass@host:5432/postgres" pgsty/pg_exporter:latest
# RPM-based systems
sudo tee /etc/yum.repos.d/pigsty-infra.repo > /dev/null <<-'EOF'
[pigsty-infra]
name=Pigsty Infra for $basearch
baseurl=https://repo.pigsty.io/yum/infra/$basearch
enabled = 1
gpgcheck = 0
module_hotfixes=1
EOF
sudo yum makecache;
sudo yum install -y pg_exporter
sudo tee /etc/apt/sources.list.d/pigsty-infra.list > /dev/null <<EOF
deb [trusted=yes] https://repo.pigsty.io/apt/infra generic main
EOF
sudo apt update;
sudo apt install -y pg-exporter
wget https://github.com/pgsty/pg_exporter/releases/download/v1.0.1/pg_exporter-v1.0.1.linux-amd64.tar.gz
tar -xf pg_exporter-v1.0.1.linux-amd64.tar.gz
sudo install pg_exporter-v1.0.1.linux-amd64/pg_exporter /usr/bin/
sudo install pg_exporter-v1.0.1.linux-amd64/pg_exporter.yml /etc/pg_exporter.yml
# Build from source
git clone https://github.com/pgsty/pg_exporter.git
cd pg_exporter
make build
Quick Start
Get PG Exporter up and running in minutes, Getting Started with:
# Run with PostgreSQL URL
PG_EXPORTER_URL='postgres://user:pass@localhost:5432/postgres' pg_exporter
# Access metrics
curl http://localhost:9630/metrics
Documentation
Live Demo
Experience PG Exporter in action with our live demo environment:
The demo showcases real PostgreSQL clusters monitored by PG Exporter, featuring:
- Real-time metrics visualization with Grafana
- Multiple PostgreSQL versions and configurations
- Extension-specific metrics and monitoring
- Complete observability stack powered by Pigsty
Community & Support
License
PG Exporter is open-source software licensed under the Apache License 2.0.
Copyright 2018-2025 © Ruohang Feng / rh@vonng.com