Skip to content

PostgreSQL + PgBouncer → Prometheus

PG Exporter

PostgreSQL observability, expressed in SQL. Define metrics in YAML and SQL; let one exporter select the right collector for each target version, role, and extension set.

600+ metrics · PostgreSQL 10–19+ · PgBouncer 1.8–1.25+

Shipped surface

Useful defaults, backed by inspectable definitions

Product coverage rather than adoption counters; every number maps to the current source tree or release archive.

600+Metricsin the merged default configInspect
58Collector filesversioned YAML + SQL definitionsInspect
10–19+PostgreSQLcovered by the default bundleInspect
35Documented tagsv0.0.1 through v1.4.1Inspect

Why PG Exporter

Metric logic database engineers can read

Collector behavior is data. The runtime owns discovery, planning, caching, failure isolation, and encoding.

01 / DECLARE

Define metrics in YAML + SQL

◇ Change the collector, not the binary

  • Map columns to GAUGE, COUNTER, HISTOGRAM, and LABEL.
  • Set TTL, timeout, skip, and fatal behavior per collector.
  • Keep custom collectors beside the shipped ones.

The metric contract stays readable to the database team.

collector.yml
pg_example:
  query: SELECT value FROM view
  min_version: 100000
  tags: [cluster, primary]
  ttl: 10
  timeout: 0.1

02 / PLAN

The right query per target

◇ One binary, target-aware execution

  • Match version, recovery role, database, user, and extensions.
  • Branch a collector instead of freezing it at the oldest version.
  • Ask /explain why a branch was chosen or skipped.

Compatibility is decided at runtime, not in release notes.

GET /explain
pg_wal / primary / PG17
pg_stat_statements / 1.11
pg_replica / role mismatch
pgbouncer / target mismatch

Production fit

A small binary with clear operational boundaries

01

Batteries included

Start with broad PostgreSQL and PgBouncer coverage, then replace only the definitions you need to own.

02

Precise control

Version gates, predicates, timeouts, cache TTLs, failure policy, and constant labels are all explicit.

03

Deploy your way

Use RPM/DEB packages, release archives, containers, Pigsty automation, or a source build.

Download and deploy

Choose the path that matches your environment

Every route runs the same PG Exporter binary and declarative collector model. The difference is lifecycle ownership.

Recommended for services

Linux packages

Install pg-exporter from the Pigsty APT/YUM repository or a versioned RPM/DEB; get systemd integration and /etc/default/pg_exporter.

Compare methods

Linux · macOS · Windows

Release archives

Download a pinned binary, merged config, service examples, license, and checksums from the GitHub release.

Compare methods

amd64 · arm64

Container image

Run the multi-architecture pgsty/pg_exporter image and mount only the configuration or CA material you need.

Compare methods

Integrated or custom

Pigsty or source

Let Pigsty deliver the complete monitoring stack, or build the tagged source with its declared Go toolchain.

Compare methods

Go from download to pg_up 1.Pick an artifact, configure one connection URL, then verify the exporter before adding the Prometheus scrape.