Skip to content

PostgreSQL + PgBouncer → Prometheus

PG Exporter

Export PostgreSQL and PgBouncer metrics to Prometheus. Define collectors in YAML and SQL. PG Exporter selects queries for the target version, role, and installed extensions.

v1.4.1 · 460 metric definitions · PostgreSQL and PgBouncer

Stable release

Start with the bundled collectors

The bundled SQL queries cover activity, replication, WAL, locks, database objects, and selected extensions.

460Metric definitionsacross the bundled SQL collectorsInspect
58Collector filesYAML files, including the schema referenceInspect
10–19PostgreSQLcollector branches in the default bundleInspect

Why PG Exporter

Define what to collect

Write the SQL and describe its result columns. PG Exporter runs the queries and converts their results to Prometheus metrics.

01 / DECLARE

Define metrics in YAML + SQL

◇ Add metrics without rebuilding

  • Map columns to GAUGE, COUNTER, HISTOGRAM, and LABEL.
  • Set a cache TTL and query timeout for each collector.
  • Load bundled and custom collectors from one directory.
collector.yml
pg_example:
  query: SELECT count(*) AS count FROM pg_stat_activity
  metrics:
    - count:
        usage: GAUGE
        description: Number of connections

02 / PLAN

The right query per target

◇ Select queries for each target

  • Select collectors by version, role, and tags.
  • Use separate query branches when server versions differ.
  • Use /explain to inspect the selected collectors.
Selection rules
version: min_version ≤ v < max_version
tags: role and operator tags
predicate: SQL returns true
/explain: selected queries

Download and deploy

Choose an installation method

Packages include a systemd service. Archives and containers let you manage the process yourself. Pigsty configures the monitoring stack.

Recommended for services

Linux packages

Install with APT or YUM. The package includes a systemd service and its configuration.

Compare methods

Linux · macOS · Windows

Release archives

Download the binary and collector configuration for your operating system.

Compare methods

amd64 · arm64

Container image

Run pgsty/pg_exporter with Docker or Kubernetes.

Compare methods

Integrated or custom

Pigsty or source

Deploy a monitoring stack with Pigsty, or build PG Exporter from source.

Compare methods

Collect your first metricsFollow the quick start to install PG Exporter and connect it to PostgreSQL.