Installation

How to download and install the pg_exporter

PG Exporter provides multiple installation methods to suit different deployment scenarios. This guide covers all available installation options with detailed instructions for each platform.

Pigsty

The easiest way to get started with pg_exporter is to use Pigsty, which is a complete PostgreSQL distribution with built-in Observability best practices based on pg_exporter, Prometheus, and Grafana. You don’t even need to know any details about pg_exporter, it just gives you all the metrics and dashboard panels

curl -fsSL https://repo.pigsty.io/get | bash; cd ~/pigsty;

Release

You can also download pg_exporter package (RPM/DEB/ Tarball) directly from the Latest GitHub Release Page:

v1.2.1 Release Files:

TypeFile
DEB (amd64)pg-exporter_1.2.1-1_amd64.deb
DEB (arm64)pg-exporter_1.2.1-1_arm64.deb
DEB (ppc64le)pg-exporter_1.2.1-1_ppc64le.deb
RPM (aarch64)pg_exporter-1.2.1-1.aarch64.rpm
RPM (x86_64)pg_exporter-1.2.1-1.x86_64.rpm
RPM (ppc64le)pg_exporter-1.2.1-1.ppc64le.rpm
Tarball (Linux amd64)pg_exporter-1.2.1.linux-amd64.tar.gz
Tarball (Linux arm64)pg_exporter-1.2.1.linux-arm64.tar.gz
Tarball (Linux ppc64le)pg_exporter-1.2.1.linux-ppc64le.tar.gz
Tarball (macOS amd64)pg_exporter-1.2.1.darwin-amd64.tar.gz
Tarball (macOS arm64)pg_exporter-1.2.1.darwin-arm64.tar.gz
Tarball (Windows amd64)pg_exporter-1.2.1.windows-amd64.tar.gz

You can install it directly with your OS package manager (rpm/dpkg), or just place the binary in your $PATH. Current tarballs also include pg_exporter.yml, package/pg_exporter.default, package/pg_exporter.service, and LICENSE for manual deployments.

Repository

The pig package is also available in the pigsty-infra repo, You can add the repo to your system, and install it with OS package manager:

YUM

For EL distribution such as RHEL,RockyLinux,CentOS,Alma Linux,OracleLinux,…:

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

APT

For Debian, Ubuntu and compatible Linux Distributions:

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

Docker

We have prebuilt docker images for amd64 and arm64 architectures on docker hub: pgsty/pg_exporter.

# Basic usage
docker run -d \
  --name pg_exporter \
  -p 9630:9630 \
  -e PG_EXPORTER_URL="postgres://user:password@host:5432/postgres" \
  pgsty/pg_exporter:latest

# With custom configuration
docker run -d \
  --name pg_exporter \
  -p 9630:9630 \
  -v /path/to/pg_exporter.yml:/etc/pg_exporter.yml:ro \
  -e PG_EXPORTER_CONFIG="/etc/pg_exporter.yml" \
  -e PG_EXPORTER_URL="postgres://user:password@host:5432/postgres" \
  pgsty/pg_exporter:latest

# With auto-discovery enabled
docker run -d \
  --name pg_exporter \
  -p 9630:9630 \
  -e PG_EXPORTER_URL="postgres://user:password@host:5432/postgres" \
  -e PG_EXPORTER_AUTO_DISCOVERY="true" \
  -e PG_EXPORTER_EXCLUDE_DATABASE="template0,template1" \
  pgsty/pg_exporter:latest

Binary

pg_exporter can be installed as a standalone binary. Download the tarball for your platform from the release page, extract it, and place the binary in your $PATH.

Compatibility

The default configuration supports PostgreSQL 10 and above. For EOL PostgreSQL versions, use the bundled legacy/ config package for compatible monitoring.

PostgreSQL VersionSupport Status
10 ~ 18+✅ Full Support (default config)
9.1 ~ 9.6⚠️ Use legacy/pg_exporter.yml
9.0 and earlier❌ Unsupported

Legacy config example:

make conf9
PG_EXPORTER_CONFIG=legacy/pg_exporter.yml pg_exporter

pg_exporter works with pgBouncer 1.8+, since v1.8 is the first version with SHOW command support.

pgBouncer VersionSupport Status
1.8.x ~ 1.25+✅ Full Support
before 1.8.x⚠️ No Metrics

Last Modified 2026-03-23: routine extension update (69102e2)