Skip to content

Download

Install PG Exporter

Use a package for a Linux service, an archive for a standalone binary, or a container image. Pigsty installs the exporter as part of a monitoring stack.

v1.6.0 · Linux · macOS · Windows · amd64 / arm64 / ppc64le

New here? Start with your first scrape

Installation methods

Choose an installation method

The Linux package name is pg-exporter. The executable and service are named pg_exporter.

For Linux services. The package includes the binary, collector configuration, systemd unit, and /etc/default/pg_exporter. Use APT or YUM for upgrades.

APT · Debian / Ubuntu
sudo apt update
sudo apt install -y curl gnupg
sudo install -d -m 0755 /etc/apt/keyrings
curl -fsSL https://repo.pigsty.io/key | gpg --dearmor | sudo tee /etc/apt/keyrings/pigsty.gpg >/dev/null
sudo chmod 0644 /etc/apt/keyrings/pigsty.gpg
sudo tee /etc/apt/sources.list.d/pigsty-infra.list > /dev/null <<'EOF'
deb [signed-by=/etc/apt/keyrings/pigsty.gpg] https://repo.pigsty.io/apt/infra generic main
EOF

sudo apt update
sudo apt install -y pg-exporter
YUM · RHEL / Rocky / Alma
curl -fsSL https://repo.pigsty.io/key | sudo tee /etc/pki/rpm-gpg/RPM-GPG-KEY-pigsty >/dev/null
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 = 1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-pigsty
module_hotfixes=1
EOF

sudo yum makecache
sudo yum install -y pg-exporter
Point it at a database and start it
# PG_EXPORTER_URL='postgres://[email protected]:5432/postgres?sslmode=disable'
sudoedit /etc/default/pg_exporter

sudo systemctl enable --now pg_exporter
curl -fsS http://127.0.0.1:9630/up

Download a specific RPM or DEB version for offline installation or controlled upgrades. Configure and start the service as shown in the package section.

RPM / DEB
DEB · amd64 / arm64 / ppc64le
# Choose amd64, arm64, or ppc64le for this host.
ARCH=amd64
curl -fLO "https://github.com/pgsty/pg_exporter/releases/download/v1.6.0/pg-exporter_1.6.0-1_$ARCH.deb"
sudo apt install "./pg-exporter_1.6.0-1_$ARCH.deb"
RPM · x86_64 / aarch64 / ppc64le
ARCH=$(uname -m)
curl -fLO "https://github.com/pgsty/pg_exporter/releases/download/v1.6.0/pg-exporter-1.6.0-1.$ARCH.rpm"
sudo dnf install "./pg-exporter-1.6.0-1.$ARCH.rpm"

Standalone binaries for Linux, macOS, and Windows. Linux supports amd64, arm64, and ppc64le; macOS supports amd64 and arm64; Windows supports amd64. For macOS, set OS=darwin below. Set ARCH=arm64 for ARM64 or ARCH=amd64 for x86-64. Extract only after the checksum command reports OK.

Extract and install
(
  set -e
  OS=linux ARCH=amd64
  ARCHIVE="pg_exporter-1.6.0.$OS-$ARCH.tar.gz"

  curl -fLO "https://github.com/pgsty/pg_exporter/releases/download/v1.6.0/$ARCHIVE"
  curl -fLO "https://github.com/pgsty/pg_exporter/releases/download/v1.6.0/checksums.txt"
  if command -v sha256sum >/dev/null 2>&1; then
    grep "  $ARCHIVE$" checksums.txt | sha256sum -c -
  else
    grep "  $ARCHIVE$" checksums.txt | shasum -a 256 -c -
  fi
  mkdir -p stage && tar -xzf "$ARCHIVE" -C stage
  sudo install -m 0755 stage/pg_exporter /usr/local/bin/pg_exporter
  sudo install -m 0644 stage/pg_exporter.yml /etc/pg_exporter.yml

  pg_exporter --version
)

A multi-architecture amd64/arm64 image. It is a scratch image: it carries the static binary, the merged config, the license, and the system CA bundle, but no shell. Mount a private CA and set sslrootcert for private PKI. Replace postgres in the example URL with a hostname reachable from the container, and set the monitoring credentials.

Container
Run a pinned image
docker run -d \
  --name pg_exporter \
  --restart unless-stopped \
  -p 127.0.0.1:9630:9630 \
  -e PG_EXPORTER_URL='postgres://monitor:S3cret@postgres:5432/postgres' \
  pgsty/pg_exporter:1.6.0

curl -fsS http://127.0.0.1:9630/up
Mount a secret and a custom collector file
docker run -d \
  --name pg_exporter \
  --restart unless-stopped \
  -p 127.0.0.1:9630:9630 \
  -e PG_EXPORTER_URL_FILE=/run/secrets/pgurl \
  -v ./pgurl:/run/secrets/pgurl:ro \
  -v ./pg_exporter.yml:/etc/pg_exporter.yml:ro \
  pgsty/pg_exporter:1.6.0

Pigsty deploys PG Exporter with metrics storage, alert rules, and Grafana dashboards. Download Pigsty, then follow its installation guide to configure your inventory and deploy the stack.

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

Build from a tag for development or custom compiler options. Follow the deployment guide to configure a service account and systemd unit.

Source
Build the exact release tag
git clone https://github.com/pgsty/pg_exporter.git
cd pg_exporter
git checkout "v1.6.0"
make build

./pg_exporter --version
PG_EXPORTER_URL='postgres://[email protected]:5432/postgres' ./pg_exporter --dry-run

Release archives and packages with their SHA-256 digests. On macOS compare shasum -a 256 <file> against the entry for that file.

All artifacts

.rpm

Download asset
FileChecksum
pg-exporter-1.6.0-1.aarch64.rpm Linuxarm64SHA-256 dd81e485377fd9bfead1b3e8000a145eb89d1c914becffaa3588cafc67731ed9
pg-exporter-1.6.0-1.ppc64le.rpm LinuxSHA-256 413f64b25feb6202bf7cf70f10d0a73527c42767a2cc2bef37beef6d33ab48ae
pg-exporter-1.6.0-1.x86_64.rpm Linuxamd64SHA-256 c25e57077f916a83993263eb0009959bbafe183fb3da4f81169629dfdbd7c64a

.deb

Download asset
FileChecksum
pg-exporter_1.6.0-1_amd64.deb Linuxamd64SHA-256 46f03078e7e74430c34d3650b48cecacc55e011c6bcecde4f3ef555076f917b3
pg-exporter_1.6.0-1_arm64.deb Linuxarm64SHA-256 d24dea8ee5774f28a8e4c5e9c9977b07d80b6e1c4d5a86a7b7802cc5d6d02a0f
pg-exporter_1.6.0-1_ppc64le.deb LinuxSHA-256 5cc839bc5f9d551559984442fcd24305e3113688dc2d92d437ed5421683e3ae0

.tar.gz

Download asset
FileChecksum
pg_exporter-1.6.0.darwin-amd64.tar.gz macOSamd64SHA-256 ddefa112d810bf5ae8acc0eeb9edc23b44609ecd577a75df8f5c2321f81fea47
pg_exporter-1.6.0.darwin-arm64.tar.gz macOSarm64SHA-256 a62d9474d091ac906a5fcd1898ffce599eaf74fb7c93800caa85b6c190d64d85
pg_exporter-1.6.0.linux-amd64.tar.gz Linuxamd64SHA-256 296a26bf83acd7024f4de8fdeac0ee31baffa01e3153cf5c694e90ed8268719a
pg_exporter-1.6.0.linux-arm64.tar.gz Linuxarm64SHA-256 ea6d1dbe0820d599e81ed702e128b4fe4a557e2afb5b5c157de222576c1d7ce7
pg_exporter-1.6.0.linux-ppc64le.tar.gz LinuxSHA-256 b720183a3c4d35d20d683bc6ba998e5eddcb1f76e5721788829aa56c2cd7155a
pg_exporter-1.6.0.windows-amd64.tar.gz Windowsamd64SHA-256 29909ef65af96f1da5e7258c7b9025c85ad1dca63596c9fba8b85b55e006bb25

Next: configure and verifyFollow the quick start to connect to PostgreSQL and verify a scrape.