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.1 · 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.

Linux packages

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

RPM / DEB

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.1/pg-exporter_1.6.1-1_$ARCH.deb"
sudo apt install "./pg-exporter_1.6.1-1_$ARCH.deb"
RPM · x86_64 / aarch64 / ppc64le
ARCH=$(uname -m)
curl -fLO "https://github.com/pgsty/pg_exporter/releases/download/v1.6.1/pg-exporter-1.6.1-1.$ARCH.rpm"
sudo dnf install "./pg-exporter-1.6.1-1.$ARCH.rpm"

Archive

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.1.$OS-$ARCH.tar.gz"

  curl -fLO "https://github.com/pgsty/pg_exporter/releases/download/v1.6.1/$ARCHIVE"
  curl -fLO "https://github.com/pgsty/pg_exporter/releases/download/v1.6.1/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
)

Container

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.1

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.1

Pigsty

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

Source

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.1"
make build

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

All artifacts

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.1-1.aarch64.rpm Linuxarm64SHA-256 d0612ad9…0277
pg-exporter-1.6.1-1.ppc64le.rpm LinuxSHA-256 73fe4587…b9b5
pg-exporter-1.6.1-1.x86_64.rpm Linuxamd64SHA-256 c20c8a80…2c82

.deb

Download asset
FileChecksum
pg-exporter_1.6.1-1_amd64.deb Linuxamd64SHA-256 0d6fe86a…e5fc
pg-exporter_1.6.1-1_arm64.deb Linuxarm64SHA-256 a055f9a7…2ab4
pg-exporter_1.6.1-1_ppc64le.deb LinuxSHA-256 f8500d01…8d4c

.tar.gz

Download asset
FileChecksum
pg_exporter-1.6.1.darwin-amd64.tar.gz macOSamd64SHA-256 496c42f3…2774
pg_exporter-1.6.1.darwin-arm64.tar.gz macOSarm64SHA-256 9ace0b48…c662
pg_exporter-1.6.1.linux-amd64.tar.gz Linuxamd64SHA-256 e8fdf64c…1fdf
pg_exporter-1.6.1.linux-arm64.tar.gz Linuxarm64SHA-256 91da5400…333b
pg_exporter-1.6.1.linux-ppc64le.tar.gz LinuxSHA-256 769e9e56…a5fb
pg_exporter-1.6.1.windows-amd64.tar.gz Windowsamd64SHA-256 0e118a98…1066

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