PG Exporter

Advanced PostgreSQL & pgBouncer Metrics Exporter for Prometheus

The ultimate monitoring experience for PostgreSQL with 600+ metrics, declarative configuration, and dynamic planning capabilities.

Get Started | GitHub | Live Demo


Features

FeatureDescription
Comprehensive MetricsMonitor PostgreSQL (10-18+) and pgBouncer (1.8-1.24+) with 600+ metrics and ~3K time series per instance
Declarative ConfigurationDefine custom metrics through YAML configs with fine-grained control over timeout, caching, and skip conditions
Custom CollectorsDefine your own metrics with declarative YAML configuration and dynamic query planning
Auto-DiscoveryAutomatically discover and monitor multiple databases within a PostgreSQL instance
Dynamic PlanningAutomatically adapt metric collection based on PostgreSQL version, extensions, and server characteristics
Production ReadyBattle-tested in real-world environments across 12K+ cores for 6+ years with enterprise reliability
Health Check APIsComprehensive HTTP endpoints for service health and traffic routing with primary/replica detection
Smart CachingBuilt-in caching mechanism with configurable TTL to reduce database load and improve performance
Extension AwareNative 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.1.1/pg_exporter-1.1.1.linux-amd64.tar.gz
tar -xf pg_exporter-1.1.1.linux-amd64.tar.gz
sudo install pg_exporter-1.1.1.linux-amd64/pg_exporter /usr/bin/
sudo install pg_exporter-1.1.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: https://g.pgsty.com

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

  • 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-2025 © Ruohang Feng / [email protected]


Last Modified 2026-01-09: add supabase asciinema demo (693cfa8)