Skip to content

Installation

Install PG Exporter from packages, release archives, containers, Pigsty, or source

Use a Linux package for a managed service, a release archive for a standalone binary, or a container for Docker and Kubernetes. Download compares these options and provides installation commands. This page lists the release files and repository setup.

Repository installation follows the repository’s current package, which can lag the GitHub release. Use the versioned release artifacts below when you need exactly v1.6.0.

Pigsty

Pigsty deploys PG Exporter with metrics storage, alert rules, and Grafana dashboards. The command below downloads Pigsty; follow its installation guide to configure and deploy the monitoring stack.

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

Release

Download RPM, DEB, or tarball files from the latest GitHub release:

v1.6.0 Release Files:

Install a downloaded RPM with sudo dnf install ./<package>.rpm, or a DEB with sudo apt install ./<package>.deb. For an archive, extract it and install the binary in your $PATH. Archives also include pg_exporter.yml, package/pg_exporter.default, package/pg_exporter.service, and LICENSE.

After installation, run pg_exporter --version. Package users can start the systemd service. For an archive installation, prepare the monitoring credentials and use the foreground example.

RPM package rename

Starting with v1.4.1, the official RPM package name and artifact prefix change from pg_exporter to pg-exporter, matching the DEB package and repository install commands. The new RPM also provides and obsoletes the legacy pg_exporter package name, allowing direct upgrades from earlier releases.

Download checksums.txt from the same release and verify files before installation. On Linux, run sha256sum -c checksums.txt --ignore-missing in the download directory; each downloaded artifact must report OK. On macOS, calculate shasum -a 256 <file> and compare its digest with the matching line in checksums.txt.

Repository

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

YUM

For EL distributions such as RHEL, Rocky Linux, CentOS, AlmaLinux, and Oracle Linux:

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

APT

For Debian, Ubuntu and compatible Linux Distributions:

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

Docker

The official image supports Linux amd64 and arm64. Pull the version you intend to deploy:

docker pull pgsty/pg_exporter:1.6.0
docker run --rm pgsty/pg_exporter:1.6.0 --version

The image includes /etc/pg_exporter.yml. Mount a replacement there for custom collectors. Auto-discovery is already enabled; set PG_EXPORTER_AUTO_DISCOVERY=false to disable it.

Use the Docker deployment example to mount the connection secret and start the container. The scratch image includes the system CA bundle and license, but no shell. Publicly trusted certificates can use the bundled roots; mount your private CA and set sslrootcert when using a private PKI with sslmode=verify-ca or verify-full.

Build from Source

Check out the release tag and use the Go version declared by its go.mod (Go 1.27.3 or later for v1.6.0):

git clone --depth 1 --branch v1.6.0 https://github.com/pgsty/pg_exporter.git pg_exporter-src
cd pg_exporter-src
go build -ldflags='-X pg_exporter/exporter.Version=v1.6.0' -o /tmp/pg_exporter .
/tmp/pg_exporter --version
sudo install -m 0755 /tmp/pg_exporter /usr/local/bin/pg_exporter
sudo install -m 0644 pg_exporter.yml /etc/pg_exporter.yml

This installs the binary at /usr/local/bin/pg_exporter. Use the foreground example to run it. For a systemd service, use an RPM/DEB package; it configures the runtime account and a service unit that runs /usr/bin/pg_exporter.

Compatibility

Use the default configuration for PostgreSQL 10 and later; it includes PostgreSQL 19 branches. PostgreSQL 9.1–9.6 uses the legacy bundle maintained on main, separately from versioned binary archives and RPM/DEB packages. Download that bundle independently of the binary:

curl -fSL https://raw.githubusercontent.com/pgsty/pg_exporter/main/legacy/pg_exporter.yml -o pg_exporter-legacy.yml
pg_exporter --config=pg_exporter-legacy.yml --url='postgres://monitor@localhost:5432/postgres'

For PostgreSQL 9.1, use main at 282e19d or later. This configuration fix handles tables without a TOAST relation; the older query can fail with could not open relation with OID 0 and omit all pg_table_size_* samples. It is a separate legacy maintenance change, not a change to the v1.6.0 binaries or their bundled default configuration. The copy in the v1.6.0 source tag does not contain it.

The bundled PgBouncer collectors require 1.8 or later. See Compatibility for version selection, architectures, and collector prerequisites.

Table reader