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://monitor@127.0.0.1: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://monitor@127.0.0.1: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 1bb4bfeb40f215a6ad3998d4399b12074bacfe03920a38784599b04eb1ca3028
pg-exporter-1.6.0-1.ppc64le.rpm LinuxSHA-256 87b248e8eab5e872146c63e7c8fff86eb8f4dcd4db5505957aff2e17043bd3a2
pg-exporter-1.6.0-1.x86_64.rpm Linuxamd64SHA-256 955ee5549aebc347fa1bd4e0517812c687d037faf17054a678fbc5bfffc4eb03

.deb

Download asset
FileChecksum
pg-exporter_1.6.0-1_amd64.deb Linuxamd64SHA-256 448c9dfc738e1425ace8cafdf44bbc677c2aee21fb89ec49faec5a8d6b3c35ef
pg-exporter_1.6.0-1_arm64.deb Linuxarm64SHA-256 e10a3823b2fb30c44eba1d6b1f833af3244a2451221c8d65071eaad32673c001
pg-exporter_1.6.0-1_ppc64le.deb LinuxSHA-256 61bc7efd5ac9a7a3bef2860a67bfa1ee0b379a09e85389ca75306aec3dee209a

.tar.gz

Download asset
FileChecksum
pg_exporter-1.6.0.darwin-amd64.tar.gz macOSamd64SHA-256 f7a57acb1ccd9fd074e6a41a8811ae0fc482a7d8db34aec508415ff0ee93f5b2
pg_exporter-1.6.0.darwin-arm64.tar.gz macOSarm64SHA-256 6c8e475ba675fa86921c07e5031db8073ddd012f198e88f66548be0d246baab7
pg_exporter-1.6.0.linux-amd64.tar.gz Linuxamd64SHA-256 e392328ca27fd7a84e3273f2cfe70d28d2e7f162dcc735fb9fb96182368a59e3
pg_exporter-1.6.0.linux-arm64.tar.gz Linuxarm64SHA-256 3795371d53388757778eea180ea91e71e51945a4864ccef315a93a230d8729fe
pg_exporter-1.6.0.linux-ppc64le.tar.gz LinuxSHA-256 ec2b7c7419a6f111494ccc777cfb86825e421b0f494aa68623e05e3c31d681f4
pg_exporter-1.6.0.windows-amd64.tar.gz Windowsamd64SHA-256 92fc6b5e58fcaa120473f59856874b8a44ea0e7388d417c5de0fbc709d6687f2

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