This is the multi-page printable view of this section. .
PG Exporter 1.5.0 Documentation
Monitor PostgreSQL with 460 metric definitions, declarative configuration, and dynamic planning.
Get Started | GitHub | Live Demo
Features
| Feature | Description |
|---|---|
| Comprehensive Metrics | 460 metric definitions cover nearly every statistics view in PostgreSQL (10-19+) and pgBouncer (1.8-1.26+) |
| Declarative Collectors | Define each metric in a YAML collector with a SQL query and execution conditions. Add, change, or remove metrics without code changes |
| Dynamic Planning | Select each collector branch for a target by version, primary/replica role, installed extensions, and tags |
| Auto-Discovery | Discover and scrape each database in an instance. The datname label identifies the database |
| Health Check APIs | Use /up, /primary, and /replica as load-balancer probes to route primary/replica traffic |
| Smart Caching | Cache each collector by TTL. Frequent probes and scrapes do not cause an equal number of database queries |
| Snapshot Histograms | Use the HISTOGRAM column type to aggregate SQL snapshots into classic Prometheus histogram distributions |
| Extension Aware | Native support for pg_stat_statements, pg_wait_sampling, citus, and timescaledb |
| Production Ready | Used in production on 12K+ cores for 6+ years |
Version Info
- Current stable release:
v1.5.0 - Default config support: PostgreSQL 10-19+
- Legacy config support: PostgreSQL 9.1-9.6 via the
legacy/config bundle - pgBouncer support: 1.8-1.26+
The v1.5.0 default bundle contains 58 YAML files (57 collector files and one configuration reference), 96 version/role branches, and 59 metric namespaces. The 460 metric names are deduplicated across branches, including disabled collectors and two unexpanded HISTOGRAM definitions. Actual time-series counts depend on versions, objects, labels, and histogram buckets.
See Release Notes for the full history.
Before upgrading, review the v1.5.0 metric changes and dashboard / alert migration checks. Retaining a metric name does not guarantee unchanged labels, state codes, or semantics; a PostgreSQL major-version upgrade also changes collector branch selection.
Design Rationale
pg_exporter uses these principles for production deployments:
- Local connections: if no URL is specified, use
postgresql:///?sslmode=disablefor a database on the same host. - Declarative collection: use YAML collector definitions to control metric behavior with
ttl,timeout,tags, andfatal. - Dynamic planning: select the collector branch at runtime from the server version, role, extensions, and tags.
- Operation during failure: startup is non-blocking by default. HTTP endpoints start even if the database is temporarily unavailable.
- Hot reload: use
POST/GET /reloadorSIGHUPto reload. Non-Windows platforms also supportSIGUSR1. - Separate probes from traffic: health endpoints use cached background probes. Each request does not need a database query.
- Protect management endpoints:
/reload,/explain, and/statexpose runtime and configuration details. In production, protect them with--web.config.fileor keep them internal.
Installation
Select an installation method for your infrastructure:
Quick Start
Follow Getting Started to start PG Exporter:
Documentation
- Getting Started - Quick start guide and basic concepts
- Installation - Installation instructions for all platforms
- Configuration - Configuration reference and examples
- Deployment - Production deployment best practices
- Collectors - Detailed documentation for all metric collectors
Live Demo
Open the PG Exporter demo: https://g.pgsty.com
The demo monitors real PostgreSQL clusters with PG Exporter. It includes:
- Real-time metrics visualization with Grafana
- Multiple PostgreSQL versions and configurations
- Extension-specific metrics and monitoring
- Complete observability stack powered by Pigsty
Community & Support
- GitHub - Source code, issues, and contributions
- Discussions - Ask questions and share experiences
- Pigsty - Complete PostgreSQL Distro with PG Exporter
License
PG Exporter is open-source software licensed under the Apache License 2.0.
Copyright 2018-2026 © Ruohang Feng / rh@vonng.com
1 - Getting Started
Follow these steps to install pg_exporter, connect to PostgreSQL, check metrics, and configure Prometheus.
You need a reachable PostgreSQL 10-19+ or pgBouncer 1.8+ instance and permission to create a user in it. For PostgreSQL 9.1-9.6, see Compatibility.
Step 1: Install
On Linux amd64, download the binary directly. For other platforms and RPM/DEB/Docker options, see the Installation guide.
Confirm the installation:
Step 2: Create a Monitoring User
Create a dedicated monitoring user on the target PostgreSQL instance.
Start with the built-in pg_monitor role in PostgreSQL 10+:
On PostgreSQL 10–13, an administrator must also run the following grant in the exporter’s main connection database to read subscription OIDs. Granting it only in the database owning the subscription is insufficient. This does not expose the password-bearing subconninfo column. PostgreSQL 14+ needs no extra grant under standard catalog ACLs.
For a local test with a superuser such as postgres, you can skip this step.
Step 3: Run and Verify
Use --dry-run to check that the configuration parses correctly. Then start the exporter:
If you do not specify a URL, pg_exporter uses postgresql:///?sslmode=disable to connect on the same host.
The URL source order is --url > PG_EXPORTER_URL > PGURL > PG_EXPORTER_URL_FILE > default.
See the Deployment guide for details.
Get the metrics from another terminal:
You should see the three core built-in metrics:
pg_up 1 shows that the connection and metric collection work.
The pg_exporter.yml bundle defines 460 distinct metric names (pg_db_*, pg_table_*, pg_wal_*, and others), with applicable metrics selected by version, role, and database objects.
If pg_up is 0, restart with pg_exporter --log.level=debug and examine the connection error.
Step 4: Hook into Prometheus
Add a scrape target in prometheus.yml:
Collectors cache results for their ttl. Most realtime collectors use ttl: 10.
If the TTL is less than the scrape interval, each scrape gets fresh data.
The cache also prevents high-frequency scrapes from overloading the database.
Do not set scrape_interval below the common collector TTLs.
For Grafana, use the PostgreSQL dashboards from Pigsty, or view the live demo.
Troubleshooting
| Symptom | What to do |
|---|---|
pg_up 0, connection fails | Run pg_exporter --log.level=debug and read the error; check URL, pg_hba.conf, and network reachability |
| Some metrics are missing | curl localhost:9630/explain to see each collector’s planning verdict (version gates, tags, predicates) |
| A collector keeps failing | curl localhost:9630/stat for per-collector error counters and durations |
| Scrapes are slow | Find the slow collector in /stat, raise its ttl, or set skip: true |
/stat, /explain, and /reload are management endpoints.
In production, protect them with --web.config.file for TLS/auth, or keep them on a trusted network.
See the API Reference.
Next Steps
- Monitor pgBouncer, enable auto-discovery, deploy with systemd / Docker / Kubernetes: Deployment guide
- Understand and customize collectors (GAUGE/COUNTER/HISTOGRAM, TTL, tags, version gates): Configuration reference
- Health check and primary/replica traffic routing endpoints (
/up,/primary,/replica): API Reference
2 - Installation
Install pg_exporter with Pigsty, YUM/APT repositories, GitHub release packages (RPM/DEB/Tarball), or Docker images. You can also build it from source.
Pigsty
Use Pigsty for the simplest installation.
Pigsty is a complete PostgreSQL distribution with monitoring based on pg_exporter, Prometheus, and Grafana.
It configures the metrics and dashboard panels for you. You do not need to configure pg_exporter separately.
Release
Download a pg_exporter package (RPM/DEB/Tarball) from the Latest GitHub Release Page:
v1.5.0 Release Files:
| Type | File |
|---|---|
| DEB (amd64) | pg-exporter_1.5.0-1_amd64.deb |
| DEB (arm64) | pg-exporter_1.5.0-1_arm64.deb |
| DEB (ppc64le) | pg-exporter_1.5.0-1_ppc64le.deb |
| RPM (aarch64) | pg-exporter-1.5.0-1.aarch64.rpm |
| RPM (x86_64) | pg-exporter-1.5.0-1.x86_64.rpm |
| RPM (ppc64le) | pg-exporter-1.5.0-1.ppc64le.rpm |
| Tarball (Linux amd64) | pg_exporter-1.5.0.linux-amd64.tar.gz |
| Tarball (Linux arm64) | pg_exporter-1.5.0.linux-arm64.tar.gz |
| Tarball (Linux ppc64le) | pg_exporter-1.5.0.linux-ppc64le.tar.gz |
| Tarball (macOS amd64) | pg_exporter-1.5.0.darwin-amd64.tar.gz |
| Tarball (macOS arm64) | pg_exporter-1.5.0.darwin-arm64.tar.gz |
| Tarball (Windows amd64) | pg_exporter-1.5.0.windows-amd64.tar.gz |
Install the package with your OS package manager (rpm/dpkg), or put the binary in your $PATH.
Current tarballs also include pg_exporter.yml, package/pg_exporter.default, package/pg_exporter.service, and LICENSE for manual deployments.
From v1.4.1, the official RPM package name and artifact prefix are pg-exporter, instead of pg_exporter.
This name matches the DEB package and repository installation commands.
The new RPM provides and obsoletes the legacy pg_exporter package name. You can upgrade directly from earlier releases.
The release page contains full SHA256 checksums in checksums.txt.
The release notes also contain checksums for each version.
Repository
The pigsty-infra repository also contains the pg_exporter package.
Add the repository to your system. Then install the package with your OS package manager:
YUM
For EL distributions such as RHEL, Rocky Linux, CentOS, AlmaLinux, and Oracle Linux:
APT
For Debian, Ubuntu and compatible Linux Distributions:
Docker
Docker Hub provides prebuilt images for the amd64 and arm64 architectures: pgsty/pg_exporter.
The current Docker image is built from scratch.
To connect to remote PostgreSQL with sslmode=verify-ca or verify-full, mount a CA certificate explicitly.
Use sslrootcert or a system CA bundle. Without this certificate, TLS verification can fail.
Compatibility
The default configuration supports PostgreSQL 10-19+.
For PostgreSQL versions that have reached EOL, use the bundled legacy/ configuration package.
| PostgreSQL Version | Support Status |
|---|---|
| 10 ~ 19+ | ✅ Full Support (default config) |
| 9.1 ~ 9.6 | ⚠️ Use legacy/pg_exporter.yml |
| 9.0 and earlier | ❌ Unsupported |
Legacy config example:
pg_exporter supports pgBouncer 1.8+.
Version v1.8 is the first pgBouncer version with SHOW command support.
| pgBouncer Version | Support Status |
|---|---|
| 1.8.x ~ 1.26+ | ✅ Full Support |
| before 1.8.x | ⚠️ No Metrics |
3 - Configuration
Each business metric in pg_exporter comes from a YAML collector definition.
A collector contains one SQL query and its execution conditions: version, role, tags, and predicates.
It also controls caching and timeout. This page describes all collector settings.
Use one YAML file, such as the default pg_exporter.yml, or a directory of YAML files.
The official default bundle combines 58 YAML files from config/ in lexicographic order: 57 collector files and one configuration reference. It defines 96 branches, 59 namespaces, and 460 distinct metric names, including disabled collectors and two unexpanded histogram definitions.
Configuration Loading
PG Exporter searches for configuration in the following order:
- Command-line argument:
--config=/path/to/config - Environment variable:
PG_EXPORTER_CONFIG=/path/to/config - Current directory:
./pg_exporter.yml - System config file:
/etc/pg_exporter.yml - System config directory:
/etc/pg_exporter/
Directory mode details:
- The exporter loads only
.yml/.yamlfiles in the specified directory. It does not read subdirectories. - It merges files in lexicographic order. A later file overrides an earlier collector definition with the same top-level name.
- If the directory contains YAML files but none can be parsed, the exporter returns an error.
- If only some files fail, the exporter logs their errors and loads the valid files. Directory loading is not all-or-nothing.
- An empty individual YAML file is a valid empty configuration; reloading it clears the collectors. A reload that fails parsing preserves the previous plan and caches.
Collector Structure
Define each collector as a top-level YAML object with a unique name and the required properties:
Validation rules:
- Each entry in
metricsmust define exactly one column mapping. - Each collector must expose at least one
GAUGE,COUNTER, orHISTOGRAMcolumn. usageaccepts onlyGAUGE,COUNTER,HISTOGRAM,LABEL, orDISCARD.- A
HISTOGRAMcolumn must definebucketwith finite upper bounds in strictly increasing order. The exporter appends the+Infbucket. - Metric and label names must follow Prometheus naming rules. The exporter checks them during loading and rejects invalid configurations immediately.
- Constant labels cannot conflict with query labels or built-in dynamic labels such as
datnameandquery. The exporter checks this during loading. If any collector usesHISTOGRAM,leis reserved and cannot be a constant label. - The SQL result must include every
LABELcolumn. Fromv1.4.1, a missing label column fails the entire collector scrape. The collector does not emit an empty label or keep stale results. Other non-fatal collectors continue. - In one-line inline
metricsdefinitions, enclosedescriptionvalues in double quotes to prevent YAML ambiguity.
Core Configuration Elements
Collector Branch Name
The top-level key uniquely identifies a collector across the entire configuration:
Query Definition
The SQL query that retrieves metrics:
Metric Types
Each column in the query result must be mapped to a metric type:
| Usage | Description | Example |
|---|---|---|
GAUGE | Instantaneous value that can go up or down | Current connections |
COUNTER | Cumulative value that only increases | Total transactions |
HISTOGRAM | Snapshot histogram deriving _bucket / _count / _sum series | Transaction age distribution |
LABEL | Use as a Prometheus label | Database name |
DISCARD | Ignore this column | Internal values |
Histogram Columns (HISTOGRAM)
Version v1.4.0 adds the HISTOGRAM column type.
Each query result row is one observation. The exporter groups observations by label to produce a classic Prometheus histogram snapshot.
It generates three series families: <name>_bucket, <name>_count, and <name>_sum.
The bucket series includes the le label and the +Inf bucket:
Usage notes:
- This is a snapshot histogram. Each scrape rebuilds the full distribution. Bucket counts can increase or decrease, as gauges do. Use
histogram_quantile()directly. Do not userate()/increase()on_count/_sum; these operations have no meaning for a snapshot. - By default, the exporter ignores SQL
NULLobservations. If you setdefault, it counts them with that value. - The exporter applies
scalebefore it assigns a bucket. As with scalar columns,scaledoes not apply to timestamps or booleans. - For a reference implementation, see the default
pg_xact_agecollector.
Cache Control (TTL)
The ttl parameter controls result caching:
Best practices:
- Set TTL less than your scrape interval
- Use longer TTL for expensive queries
- TTL of 0 disables caching
- Collector and predicate TTLs must be finite, nonnegative, and fit in Go
time.Duration. v1.5.0 rejects NaN, infinities, and excessively large values.
Timeout Control
Prevent queries from running too long:
Omitting timeout or setting it to 0 selects the 100ms default; a finite negative value disables the query deadline. v1.5.0 rejects NaN, infinities, and positive timeouts that would overflow. The timeout covers the predicates and main query together.
Version Compatibility
Control which PostgreSQL versions can run this collector:
Version numbers follow PostgreSQL server_version_num rules:
100000= 10.0130002= 13.2160001= 16.1190000= 19.090600= 9.6, relevant when using the legacy config bundle
Execution Model
Use the execution model to find why a metric is missing:
- Planning runs on the first scrape, configuration reload, or metadata change. It checks each branch’s target type (PostgreSQL / pgBouncer),
min_version/max_version,tags, andskipsetting. Tags must match the server role and exporter tags. A branch that fails any check is not installed on the target. Usecurl localhost:9630/explainto see each decision. - Scraping runs on each
/metricsrequest. An installed collector returns cached results while they are withinttl. Otherwise, it first runspredicate_queries. A false result skips the collector for this round and incrementspg_exporter_query_scrape_predicate_skip_count. If all predicates pass, the main query runs withtimeout. The exporter converts the results to metrics and caches them. - Failure semantics: a normal collector failure affects only that collector. It increments
pg_exporter_query_scrape_error_countand omits its metric group for this round. A failed collector withfatal: truefails the entire server scrape.
In v1.5.0, a successful precheck compares the username, schemas, and extensions. A change triggers replanning; adding or removing a schema or extension does not require a manual reload. Unchanged sets preserve plans and caches; replanning resets query caches and statistics.
Tag System
Tags control when and where collectors execute:
Built-in Tags
| Tag | Description |
|---|---|
cluster | Execute once per PostgreSQL cluster |
primary / master | Only on primary servers |
standby / replica | Only on replica servers |
pgbouncer | Only for pgBouncer connections |
Prefixed Tags
| Prefix | Example | Description |
|---|---|---|
dbname: | dbname:postgres | Only on specific database |
username: | username:monitor | Only with specific user |
extension: | extension:pg_stat_statements | Only if extension installed |
schema: | schema:public | Only if schema exists |
not: | not:slow | NOT when exporter has tag |
Custom Tags
Pass custom tags to the exporter:
Then use the tags in the configuration:
Predicate Queries
Run conditional checks before the main query:
The main query only executes if all predicates return true.
Metric Definition
Basic Definition
Advanced Options
Collector Organization
PG Exporter ships with pre-organized collectors:
| Range | Category | Description |
|---|---|---|
| 0xx | Documentation | Examples and documentation |
| 1xx | Basic | Server info, settings, metadata |
| 2xx | Replication | Replication, slots, receivers |
| 3xx | Persistence | I/O, checkpoints, WAL |
| 4xx | Activity | Connections, locks, queries |
| 5xx | Progress | Vacuum, index creation progress |
| 6xx | Database | Per-database statistics |
| 7xx | Objects | Tables, indexes, functions |
| 8xx | Optional | Expensive/optional metrics |
| 9xx | pgBouncer | Connection pooler metrics |
| 10xx+ | Extensions | Extension-specific metrics |
Real-World Examples
Simple Gauge Collector
Counter with Labels
Version-Specific Collector
Extension-Dependent Collector
Custom Collectors
Creating Your Own Metrics
- Create a new YAML file in your config directory:
- Test your collector:
Conditional Metrics
Use predicate queries for conditional metrics:
Performance Optimization
Query Optimization Tips
Use appropriate TTL values:
- Fast queries: 1-10 seconds
- Medium queries: 10-60 seconds
- Expensive queries: 300-3600 seconds
Set realistic timeouts:
- Default: 100ms
- Complex queries: 500ms-1s
- Never disable timeout in production
Use cluster-level tags:
Disable expensive collectors:
Monitoring Collector Performance
Check collector execution statistics:
Metric and Alert Upgrade Checks
When upgrading the exporter, merge and deploy the matching collector YAML. Replacing only the binary does not apply SQL, label, or state-code corrections. For instances managed by Pigsty, also verify that the deployed configuration contains these definitions. After a PostgreSQL major-version upgrade, check the newly selected collector branches.
- Exporter v1.4.1 → v1.5.0: bundled SQL metric names, types, and units stay unchanged, but
pg_sub_*addsdatnameandpg_recv_statecorrects its state codes. Review joins/aggregations for subscriptions with the same name in different databases, and Grafana value mappings. - PG18 → PG19: existing metrics are not removed or renamed, but
pg_sub_sync_error_countbroadens to table plus sequence synchronization errors, andpg_subrel_countincludes sequences.pg_sub_has_workerdistinguishes a subscription row from a running apply worker; the presence ofpg_sub_idalone is insufficient. - Crossing PG17 / PG18: some
pg_bgwriter_*metrics need to move topg_checkpointer_*or backend-filtered I/O metrics. From PG18 onward,pg_wal_write,pg_wal_sync,pg_wal_write_time, andpg_wal_sync_timeneed to move topg_io_*{object="wal"}, with corresponding label aggregation changes. See the metric-by-metric migration table.
See the v1.5.0 release notes and PG19 metric table for the full changes. PG19 support first shipped in v1.3.0, and acceptance evidence refers to 19 RC1; these notes do not establish runtime validation of every dashboard.
Before and after deployment, inspect /metrics, /explain, /stat, pg_exporter_query_scrape_error_count, and the logs. Evaluate the actual dashboard, recording-rule, and alert expressions, checking returned series, labels, units, and state mappings. Use promtool check rules for syntax and promtool test rules for both normal and missing-series input. HTTP 200, up == 1, or pg_up == 1 does not prove that every expected metric exists; an empty vector is not a healthy zero.
For PG19 targets expected to expose the bundled WAL collector, use this per-target missing-metric check with for: 5m in the alert rule:
job="pg19" is an example: replace it with the actual target selector and include any additional identity labels in matching. Monitor up and pg_up failures separately. Scope absence checks by version, primary/replica role, and expected objects; for example, a primary should not require pg_recovery_state_*. Do not mask missing input with an unconditional or vector(0). Fleet-wide absent(metric) also misses one target’s disappearance while other targets still emit data. See the complete missing-metric rule.
Troubleshooting Configuration
Validate Configuration
Common Issues
| Problem | Solution |
|---|---|
| Metrics missing | Check tags and version compatibility |
| Slow scrapes | Increase TTL, add timeout, disable expensive queries |
| High memory usage | Reduce result set size, use LIMIT |
| Permission errors | Verify query permissions for monitoring user |
Debug Logging
Enable debug logging to troubleshoot:
4 - API Reference
pg_exporter provides four types of HTTP endpoints: metrics, health checks, traffic routing, and operational management.
The default listen port is :9630. The following table lists all endpoints:
| Endpoint | Method | Description |
|---|---|---|
/metrics | GET | Prometheus metrics endpoint (path configurable via --web.telemetry-path) |
/up | GET | Aliveness check; aliases /health, /liveness, /readiness, /read |
/primary | GET | Primary check; aliases /leader, /master, /read-write, /rw |
/replica | GET | Replica check; aliases /standby, /slave, /read-only, /ro |
/reload | GET/POST | Hot-reload collector configuration |
/explain | GET | Show per-collector planning decisions |
/stat | GET | Per-collector runtime statistics (hits / errors / duration) |
/version | GET | Version and build information (plain text) |
/ | GET | Landing page linking to the metrics endpoint |
Health and routing endpoints return the cached state from background probes: primary, replica, down, starting, or unknown.
They do not query the database for each HTTP request. In v1.5.0, each response reads one atomic state snapshot, so its HTTP status and body always describe the same state. The cached state can still lag behind the database. A successful PgBouncer probe maps to primary; it does not describe the role of its PostgreSQL backend.
Metrics Endpoint
GET /metrics
This endpoint returns all collected metrics in Prometheus format.
Request
Response
Response Format
Metrics follow the Prometheus exposition format:
Self-Monitoring Metrics
In addition to metrics from YAML collectors, /metrics returns the exporter’s runtime metrics.
Use --disable-intro to disable the pg_exporter_* metrics.
The prefix follows --namespace. In pgBouncer mode, the prefix is pgbouncer_.
| Metric | Labels | Description |
|---|---|---|
pg_up | — | 1 when the target database is reachable, 0 otherwise |
pg_version | — | Server version in server_version_num format |
pg_in_recovery | — | 1 when in recovery mode (replica) |
pg_exporter_build_info | version, revision, … | Constant 1 with build info in labels |
pg_exporter_up | — | Constant 1 while the exporter is alive |
pg_exporter_uptime | — | Seconds since the exporter started |
pg_exporter_scrape_total_count / _error_count | — | Cumulative scrape / failure counts |
pg_exporter_scrape_duration | — | Duration of the last scrape in seconds |
pg_exporter_last_scrape_time | — | Timestamp of the last scrape |
pg_exporter_server_scrape_* | datname | Per-database scrape duration and success/failure counters |
pg_exporter_query_scrape_duration | datname, query | Last execution duration per collector |
pg_exporter_query_scrape_total_count / _error_count | datname, query | Execution / failure counts per collector |
pg_exporter_query_scrape_hit_count / _metric_count | datname, query | Rows returned / metrics emitted per collector |
pg_exporter_query_scrape_predicate_skip_count | datname, query | Times skipped because a predicate returned false |
pg_exporter_query_cache_ttl | datname, query | Result cache TTL per collector |
Use pg_exporter_query_scrape_duration and _error_count to identify slow or failed collectors.
These metrics provide a machine-readable equivalent of /stat.
Health Checks
Health endpoints provide multiple ways to monitor PG Exporter and the target database state.
GET /up
This endpoint checks availability from the cached background probe state. It does not probe the database for each HTTP request.
Response Codes
| Code | Status | Description |
|---|---|---|
| 200 | OK | Target is available (primary / replica) |
| 503 | Service Unavailable | Target is unavailable (down / starting / unknown) |
Example
GET /health
Alias of /up with identical behavior.
GET /liveness and GET /readiness
These aliases use the same handler and behavior as /up. Use them for Kubernetes probes:
Both endpoints return 503 when the target database is unreachable. To prevent a database failure from restarting the exporter Pod, use a TCP liveness probe on the listen port.
Traffic Routing
Load balancers and proxies use these endpoints to route traffic by server role.
GET /primary
Check whether the server is a primary instance.
Response Codes
| Code | Status | Description |
|---|---|---|
| 200 | OK | Server is primary and accepting writes |
| 404 | Not Found | Server is not primary and is acting as a replica |
| 503 | Service Unavailable | Server is unavailable (down / starting / unknown) |
Aliases
/leader/master/read-write/rw
Example
GET /replica
Check whether the server is a replica instance.
Response Codes
| Code | Status | Description |
|---|---|---|
| 200 | OK | Server is a replica and in recovery |
| 404 | Not Found | Server is not a replica and is acting as primary |
| 503 | Service Unavailable | Server is unavailable (down / starting / unknown) |
Aliases
/standby/read-only/ro
/slave remains compatible, but /replica is the preferred name.
Example
GET /read
Check whether the server can handle read traffic. Both primaries and replicas may return success.
Response Codes
| Code | Status | Description |
|---|---|---|
| 200 | OK | Server is healthy and can handle reads |
| 503 | Service Unavailable | Server is unavailable (down / starting / unknown) |
Example
Operational Endpoints
GET /reload / POST /reload
Reload configuration without restarting the exporter.
Request
Response
Response Codes
| Code | Status | Description |
|---|---|---|
| 200 | OK | Reload completed successfully |
| 500 | Internal Server Error | Reload failed and returns fail to reload: ... |
| 405 | Method Not Allowed | Non-GET/POST request, with Allow: GET, POST |
Use Cases
- Update collector definitions
- Change query parameters
- Modify cache TTL values
- Add or remove collectors
Reload updates collector configuration, query plans, caches, and query statistics. A parsing failure preserves the previous plan and caches. Empty YAML is a valid empty configuration; a successful reload clears the collectors. Directory mode permits partial file loading; see Configuration Loading. To change process settings, such as listen addresses or CLI arguments, restart the exporter.
/reload, /explain, and /stat are management endpoints.
If the exporter is reachable outside localhost or a trusted private network, protect these endpoints.
Use --web.config.file, or restrict access through a reverse proxy or firewall.
GET /explain
Display planned collector execution details for all configured collectors.
Request
Response
GET /stat
Show runtime statistics, including collector execution times and success/error counters.
Request
Response
Use this endpoint to identify slow or failed collectors.
Using with Load Balancers
HAProxy Example
A Note on Nginx
Open-source Nginx does not support active HTTP health checks outside the traffic connection.
The health_check directive requires NGINX Plus.
PostgreSQL traffic also requires the stream module instead of http proxying.
To route PostgreSQL traffic by role, use HAProxy as shown above, or a solution such as Patroni + vip-manager.
5 - Deployment
Use this page to deploy pg_exporter in production.
It describes process arguments, environment variables, monitoring users, credentials, and deployment with systemd, Docker, or Kubernetes.
It also describes pgBouncer monitoring, auto-discovery, Prometheus scrapes, and alerts.
The exporter reads process configuration from two sources. Command-line arguments take precedence:
- Command-line arguments (
--url,--config, …) - Environment variables (every flag has a corresponding
PG_EXPORTER_*variable)
YAML collector definitions control metric collection.
The default file is /etc/pg_exporter.yml. You can also use a configuration directory.
See the Configuration reference.
Command-Line Arguments
The full flag list from pg_exporter --help:
These behaviors affect deployment:
- Startup policy: startup is non-blocking by default. If the database is unreachable, HTTP endpoints still start. A background probe retries until recovery. To fail when the database is unreachable, set
--fail-fast. For example, use this option when systemd or an orchestrator controls restarts. - Telemetry path validation:
--web.telemetry-pathrejects empty paths, conflicts with built-in endpoints, and non-canonical paths such as//metrics. v1.5.0 also verifies that the active HTTP mux selects the metrics handler, preventing escaped paths from returning the landing page or a redirect. Prefer an unescaped path such as/metrics.
Connection URL Sources
The exporter checks these sources in order, skipping empty command-line and environment values:
--url/-ucommand-line argumentPG_EXPORTER_URLenvironment variablePGURLenvironment variable- Content of the file pointed to by
PG_EXPORTER_URL_FILE(fits container Secret mounts) - Default
postgresql:///?sslmode=disable(local-first, fits same-host deployment)
Once PG_EXPORTER_URL_FILE is selected, an unreadable, empty, or whitespace-only file prevents startup; it does not fall back to the local default.
v1.5.0 validates URL syntax, percent escapes, and query parameter names. Names cannot be empty or contain whitespace or =, and URLs cannot contain an unescaped #. Invalid input stops startup with a fixed diagnostic that omits the raw connection string, preventing password disclosure or silently discarded TLS settings. Valid URL passwords in user information and password= parameters are redacted in logs.
If the URL omits sslmode, the exporter appends sslmode=disable.
At startup, it also clears libpq service-file environment variables, such as PGSERVICE / PGSERVICEFILE, and logs this action.
Service files can override an explicit connection target.
Clearing these variables ensures that the exporter connects to the URL shown in the log.
Monitoring User and Credentials
Create the Monitoring User
On PostgreSQL 10–13, an administrator must also run the following grant in the exporter’s main connection database to read subscription OIDs. Granting it only in the database owning the subscription is insufficient. This does not expose the password-bearing subconninfo column. PostgreSQL 14+ needs no extra grant under standard catalog ACLs.
Size CONNECTION LIMIT for the number of discovered databases. A limit that is too low can prevent connections to additional databases. Keep a connection limit to prevent connection exhaustion if the configuration is incorrect.
The exporter normally uses one to a few connections. With auto-discovery, it uses one connection per database.
Manage Passwords with .pgpass
Remove the password from the URL. Use libpq’s .pgpass file to supply it:
Packaged services run as the prometheus system user.
From v1.4.0, its HOME is /var/lib/prometheus. Libpq looks for ~/.pgpass there.
The package does not create this directory. Before you use .pgpass, run:
install -d -o prometheus -g prometheus /var/lib/prometheus
TLS for the Database Connection
Protecting the HTTP Port
The HTTP port provides /metrics and the management endpoints /reload, /explain, and /stat.
Anyone with access to the port can read configuration and runtime state, or start a reload.
On a shared network, enable TLS / Basic Auth with --web.config.file (exporter-toolkit web configuration).
You can also restrict access through a firewall or reverse proxy.
Systemd Deployment (RPM/DEB packages)
RPM/DEB packages include a service unit and an environment file. After installation, edit the environment file and start the service:
Environment file /etc/default/pg_exporter (package defaults):
Each command-line flag has an environment variable. Add the variables you need, such as PG_EXPORTER_DISABLE_INTRO.
The file uses the noreplace package option. Upgrades do not overwrite your changes.
Common operations:
Docker Deployment
Docker Compose:
The official image is built from scratch. It contains no system CA certificates.
To connect to remote PostgreSQL with sslmode=verify-ca / verify-full, mount a CA certificate and set sslrootcert to its path.
Without the certificate, TLS verification cannot complete.
Kubernetes Deployment
To keep the connection string out of environment variables, set PG_EXPORTER_URL_FILE to a Secret-mounted file.
Auto-Discovery
Auto-discovery is enabled by default. It lets one exporter instance monitor every database in the target PostgreSQL instance:
Behavior:
- Cluster-level collectors (
tags: [cluster]) run once on the primary connection - Database-level collectors run on every discovered database, with metrics distinguished by the
datnamelabel - Newly created or dropped databases are added or removed during subsequent prechecks
- v1.5.0 uses
lib/pqto resolve the actual database identity. Replacing the database name removes conflictingdbname/databasequery parameters and preserves special characters, preventing discovered connections from scraping the same database - Database scrapes remain sequential. Allow enough scrape timeout for prechecks and queries across all databases
Monitoring pgBouncer
Set the database name in the URL to pgbouncer. This name activates pgBouncer mode:
In pgBouncer mode, the exporter uses the pgbouncer metric prefix.
It runs only pgBouncer collectors, such as SHOW STATS / SHOW POOLS.
Usually, you run one exporter for PostgreSQL and another for pgBouncer. Give each exporter a different port.
Prometheus Scraping and Alerting
Scrape Configuration
Kubernetes service discovery:
Set the scrape interval equal to or greater than the common collector ttl.
Most collectors in the default bundle use 10 seconds.
More frequent scrapes return cached results until the TTL expires.
Alert Rules
The following rules use available metrics:
Role-Based Traffic Routing
Use /primary, /replica, and /read as health probes for HAProxy or similar load balancers.
These endpoints support primary/replica routing to separate read and write traffic.
For endpoint behavior and a complete HAProxy example, see the API Reference.
Open-source Nginx does not support active HTTP health checks outside the traffic connection.
The health_check directive requires NGINX Plus.
To route PostgreSQL traffic by role, use HAProxy or a solution such as Patroni + vip-manager.
6 - Release Notes
The latest stable version of pg_exporter is v1.5.0
| Version | Date | Summary | GitHub |
|---|---|---|---|
| v1.5.0 | 2026-10-23 | Connection safety, discovery, health and replication fixes; Go 1.27.3 | v1.5.0 |
| v1.4.1 | 2026-07-29 | Subscription count and label validation fixes; RPM rename | v1.4.1 |
| v1.4.0 | 2026-07-18 | Snapshot histograms, pg_xact_age collector, HTTP hardening | v1.4.0 |
| v1.3.0 | 2026-06-24 | PostgreSQL 19 support, new PG19 collectors and branches | v1.3.0 |
| v1.2.2 | 2026-04-14 | Routine Go 1.26.2 refresh, no functional changes | v1.2.2 |
| v1.2.1 | 2026-03-21 | Config style cleanup, Go 1.26.1 refresh | v1.2.1 |
| v1.2.0 | 2026-02-12 | Hot reload, non-blocking startup, PG9.x legacy support | v1.2.0 |
| v1.1.2 | 2026-01-16 | fix pg_timeline conf issue, build with latest deps | v1.1.2 |
| v1.1.1 | 2025-12-30 | New pg_timeline collector, pg_sub_16 branch, bug fixes | v1.1.1 |
| v1.1.0 | 2025-12-15 | Update default metrics collectors, bump to go 1.25.5 | v1.1.0 |
| v1.0.3 | 2025-11-20 | Routine update on 1.25.4, fix unsupported libpq env | v1.0.3 |
| v1.0.2 | 2025-08-14 | Build for more os arch with goreleaser | v1.0.2 |
| v1.0.1 | 2025-07-17 | DockerHub images, Go 1.24.5, disable pg_tsdb_hypertable | v1.0.1 |
| v1.0.0 | 2025-05-06 | PostgreSQL 18 support, new WAL/checkpointer/I/O metrics | v1.0.0 |
| v0.9.0 | 2025-04-26 | TimescaleDB, Citus, pg_wait_sampling collectors | v0.9.0 |
| v0.8.1 | 2025-02-14 | Dependencies update, docker image tags | v0.8.1 |
| v0.8.0 | 2025-02-14 | PgBouncer 1.24 support, Go 1.24, logging refactor | v0.8.0 |
| v0.7.1 | 2024-12-29 | Routine update, configuration as Reader support | v0.7.1 |
| v0.7.0 | 2024-08-13 | PostgreSQL 17 support, predicate queries feature | v0.7.0 |
| v0.6.0 | 2023-10-18 | PostgreSQL 16 support, ARM64 packages, security fixes | v0.6.0 |
| v0.5.0 | 2022-04-27 | RPM/DEB builds, column scaling, metrics enhancements | v0.5.0 |
| v0.4.1 | 2022-03-08 | Collector updates, connect-timeout parameter | v0.4.1 |
| v0.4.0 | 2021-07-12 | PostgreSQL 14 support, auto-discovery feature | v0.4.0 |
| v0.3.2 | 2021-02-01 | Shadow DSN fixes, documentation updates | v0.3.2 |
| v0.3.1 | 2020-12-04 | Configuration fixes for older PostgreSQL versions | v0.3.1 |
| v0.3.0 | 2020-10-29 | PostgreSQL 13 support, REST APIs, dummy server | v0.3.0 |
| v0.2.0 | 2020-03-21 | YUM packages, configuration reload support | v0.2.0 |
| v0.1.2 | 2020-02-20 | Dynamic configuration reload, bulky mode | v0.1.2 |
| v0.1.1 | 2020-01-10 | Startup hang bug fix | v0.1.1 |
| v0.1.0 | 2020-01-08 | Initial stable release | v0.1.0 |
| v0.0.4 | 2019-12-20 | Production tested release | v0.0.4 |
| v0.0.3 | 2019-12-14 | Production environment testing | v0.0.3 |
| v0.0.2 | 2019-12-09 | Early testing release | v0.0.2 |
| v0.0.1 | 2019-12-06 | Initial release with PgBouncer mode | v0.0.1 |
v1.5.0
Release date: 2026-10-23. This release improves connection security, collection accuracy, and runtime state consistency, and upgrades the build toolchain to Go 1.27.3.
Fixes and Improvements
- Validate PostgreSQL URLs and query parameters strictly. Reject malformed escapes and parameter names containing whitespace or
=. Safe diagnostics prevent malformed connection strings from leaking passwords into logs or silently discarding explicit TLS settings. An empty or whitespace-only file selected throughPG_EXPORTER_URL_FILEnow prevents startup. - Resolve database identities with
lib/pq. Auto-discovery removes conflictingdbname/databasequery parameters when replacing a database name and preserves special characters, fixing duplicate collection and HTTP 500 responses caused by duplicate metrics. - Generate each health response’s HTTP status and body from one atomic state snapshot, fixing contradictory responses during concurrent state transitions. Health checks still use background cached state.
- Replan after a successful precheck detects changes to the username, schemas, or extensions. Unchanged metadata preserves plans and caches. Adding or removing a schema or extension no longer requires manual reload.
- Reject NaN, infinities, and overflowing TTLs or positive timeouts during configuration loading. Preserve the existing meanings of zero TTL (disable caching), zero timeout (use the default), and finite negative timeout (disable the deadline).
- Verify at startup that the active HTTP mux routes the metrics path to the metrics handler. Reject escaped paths that would return the landing page or a redirect under the legacy mux.
- Add the owning database’s
datnamelabel topg_sub_*, preventing collisions between identically named subscriptions in different databases. Correctpg_recv_statecodes in the current and legacy bundles, and fix receiver address extraction on PostgreSQL 9.6. - Clarify
pg_originpermissions, the table scope ofpg_pubrel_count, synchronization states and PostgreSQL 19 sequence semantics inpg_subrel_count, and thepg_backenddescription.
Metric and dashboard compatibility
Compared with v1.4.1 on the same PostgreSQL version, v1.5.0 does not add, remove, or rename bundled SQL metric names. Types and units remain unchanged, but labels and state mappings do change. PostgreSQL 19 support first shipped in v1.3.0; upgrading the database can also change the selected SQL branch and a metric’s meaning.
| Scope | Metrics | Compatibility action |
|---|---|---|
| v1.5.0 configuration | pg_sub_* | Adds datname to every sample. Keep database and subscription identity in joins and aggregations; new label sets create new time series. |
| v1.5.0 configuration | pg_recv_state | Real receiver states starting, waiting, restarting, and stopped now map to 6–9 instead of -1. Update value mappings and state alerts; codes 1–3 are reserved. |
| PG18 → PG19 | Existing PG18 metric names | None are removed or renamed by the PG19 branches in this bundle. This does not guarantee unchanged semantics or labels from PostgreSQL itself. |
| PG19 | pg_sub_sync_error_count | Keeps the name but becomes the sum of table and sequence synchronization errors. For table-only alerts, use pg_sub_sync_table_error_count; pg_sub_sync_seq_error_count reports the sequence component. Do not double-count the components and their sum. |
| PG19 | pg_sub_has_worker, pg_sub_reset_time, pg_sub_confl_* | Adds worker presence, reset time, and eight conflict counters. The subscription row can remain without an apply worker; metric presence alone is not a worker-health check. |
| PG19 | pg_subrel_count | Includes sequences as well as tables; pg_pubrel_count still counts tables only. Review panel labels and count comparisons. |
| PG19 | pg_wal_fpi_bytes, pg_lock_stat_*, pg_recovery_state_*, pg_vacuum_score_* | Additive metrics. Recovery state is replica-only; autovacuum scores are primary-only. Existing WAL, lock-distribution, and recovery families remain. |
Users upgrading from PG17 or earlier must also migrate older names: checkpoint metrics left pg_bgwriter_* in PG17, and pg_wal_write, pg_wal_sync, pg_wal_write_time, and pg_wal_sync_time are absent from PG18 onward. The full compatibility guide lists each replacement, label/aggregation differences, and mixed-version PromQL.
Before rollout, evaluate the actual dashboard and alert expressions and test missing-series input. A successful scrape does not ensure every expected metric exists; an empty alert expression can silently stop firing. The missing-metric checks include a per-target rule and explain when absence is expected. The full PG19 metric table links to the tagged collector definitions; PostgreSQL validation remains scoped to 19 RC1.
Upgrade Notes
- On PostgreSQL 10–13, an administrator must run
GRANT SELECT (oid) ON pg_catalog.pg_subscription TO monitor;in the exporter’s main connection database, substituting the actual monitoring role. This does not exposesubconninfo. PostgreSQL 14+ needs no extra grant under standard catalog ACLs. - The new
datnamelabel onpg_sub_*creates new time series. Review PromQL joins, aggregations, and alerts that match these labels. Thepg_sub_idgauge is retained. pg_recv_stateuses the following codes; 1–3 remain reserved. No receiver row means no sample. PostgreSQL 9.6 still hides receiver details from ordinary monitoring roles, resulting in an unknown state; the exporter does not expand database privileges.
| State | Code | State | Code |
|---|---|---|---|
| streaming | 0 | starting | 6 |
| stopping | 4 | waiting | 7 |
| connecting (PG19+) | 5 | restarting | 8 |
| unknown / NULL | -1 | stopped | 9 |
- Upgrade both the binary and collector configuration. Packages preserve local configuration changes: merge the new
pg_exporter.yml, then check query error counters in/metrics. HTTP 200 alone does not establish a successful scrape. - Reloading empty YAML still clears collectors, and directory loading still permits valid files to load when others fail. SIGTERM retains immediate process termination; it does not wait for active scrapes to complete.
Toolchain and Validation
Retain lib/pq 1.12.3 and upgrade Prometheus client_golang to 1.25.0, common to 0.72.1, and exporter-toolkit to 0.20.0. YAML uses go.yaml.in/yaml/v3 3.0.5. The PostgreSQL driver remains lib/pq.
The default bundle still contains 58 YAML files, 96 branches, 59 namespaces, and 460 distinct metric definitions, including two unexpanded histograms. Validation covered non-superuser collection on PostgreSQL 9.1–9.6, 10–18, 19 RC1, and PgBouncer 1.26.1; physical standby promotion, reloads, disconnect recovery, races, both HTTP mux modes, six-platform builds, ARM64 RPM/DEB installation, and Docker images. PostgreSQL 19 testing used RC1; this does not cover every extension or production workload.
Go and Dependency Security Updates
Go 1.27.3 adds a blocklist for untrusted intermediate certificates in crypto/x509, addressing CVE-2026-111943. It also includes security fixes accumulated since the previous Go 1.26.5 build, including TLS issues CVE-2026-56862 and CVE-2026-97031, HTTP issues CVE-2026-56853 and CVE-2026-94439, and template, ASN.1, and multipart fixes. See the complete upstream scope in the Go 1.26.6, Go 1.27.2, and Go 1.27.3 announcements.
golang.org/x/net moves from 0.57.0 to 0.61.0, including five HTTP/2 fixes introduced in 0.60.0:
| CVE | Fix |
|---|---|
| CVE-2026-78659 | Memory amplification through Trailer headers |
| CVE-2026-78669 | CPU consumption through window updates |
| CVE-2026-78663 | Duplicate flow-control credit refunds |
| CVE-2026-97032 | HPACK encoder race and crash |
| CVE-2026-78660 | Malformed framing response headers |
x/crypto 0.58.0 also crosses the fixes for SSH issues CVE-2026-56854, CVE-2026-56855, and CVE-2026-78662. x/text 0.43.0 includes the precis fix CVE-2026-56851. The exporter does not import these SSH/precis packages; these are dependency-version updates, not confirmed exporter runtime vulnerabilities.
Comparative govulncheck runs on 2026-10-23 found no known symbol-level or imported-package-level vulnerabilities in the new candidate for Darwin, Linux, or Windows. The unimported OpenPGP package retains a module-level advisory, GO-2026-5932. Static symbol matches are not exploit reproductions, and including upstream fixes does not establish that every issue was exploitable in the exporter. Other dependency upgrades are maintenance updates. Install the rebuilt release binary; upgrading Go on the host does not change an existing binary.
For the full CVE table, first fixed versions, and scan levels, see the security update verification.
GitHub release · SHA256 checksums · Full changelog · Complete collector reference
v1.4.1
v1.4.1 is a maintenance release focused on metric accuracy and RPM upgrade compatibility.
Highlights:
- Fix
pg_subrel_countovercounting with parallel logical replication apply workers. Deduplicatepg_stat_subscriptionby subscription ID and name before aggregating subscription relation states. - If a query result omits a configured
LABELcolumn, fail the entire collector scrape. Do not emit an empty label or keep stale results. Other non-fatal collectors continue normally. - Rename the official RPM package and artifact prefix from
pg_exportertopg-exporter. The new package provides and obsoletes the legacy name to support direct upgrades. - Update version and standalone package metadata. Add regression tests for missing labels. Validate RPM configuration, artifact names, and compatibility metadata in CI.
Upgrade Notes:
- Custom collector SQL must return every
LABELcolumn. The result schema must be complete even if the query returns zero rows. - If automation matches GitHub RPM file names directly, change
pg_exporter-*.rpmtopg-exporter-*.rpm.
https://github.com/pgsty/pg_exporter/releases/tag/v1.4.1
v1.4.0
v1.4.0 adds Snapshot Histogram metrics and the pg_xact_age transaction age collector.
It also improves HTTP routing, packaging, and the build toolchain.
New Features:
- Add the
HISTOGRAMcolumn type. It aggregates SQL snapshots by label group into classic Prometheus histograms with_bucket/_count/_sumseries. Configuration loading validates finite bucket bounds in strictly increasing order and appends+Infautomatically. Thelelabel is reserved. Hot reload is supported. - Add the
pg_xact_agecollector. It returns open transaction age (pg_xact_age_seconds) and idle-in-transaction age (pg_xact_age_idle_seconds) as histograms. It collects cluster-level data from client backends only, with a 10s TTL. - Increase the default bundle from 57 to 58 definition files. Assign
pg_xact_ageto slot0450. Renumberpg_lock/pg_lock_stat/pg_queryto0460/0470/0480without content changes.
Fixes & Improvements:
- Register HTTP routes in a private ServeMux instead of the global
DefaultServeMux. This prevents accidental exposure of endpoints from third-party libraries. - Validate
--web.telemetry-pathat startup. Reject empty paths, paths without a leading/, paths with?#{}, and conflicts with built-in endpoints. Also reject non-canonical paths such as//metrics, which cannot match requests. Each failure returns a clear error immediately. - Escape the telemetry path in the landing page HTML.
- Close the primary connection pool if the
--fail-fastpre-check fails. - Fix RPM / DEB packaging (#105). Set the
prometheususer’s HOME to/var/lib/prometheus, where libpq looks for~/.pgpass. Add/postgresto the packaged default URL. This prevents libpq from using a database named after the OS user. - Use the
vversion prefix consistently. Official release binaries reportv1.4.0in--version,/version, andpg_exporter_build_info{version=...}. GoReleaser artifacts previously reported1.3.0without the prefix. Artifact file names, package versions, and Docker image tag conventions do not change. - Apply the same value conversion rules to histograms and scalar columns. Exclude timestamps and booleans from
scale. - Correct GoReleaser package metadata to show support for PostgreSQL
9.x - 19+and pgBouncer1.8 - 1.25+. - Restore
GOPROXY/GOSUMDBbuild-argument passthrough inmake docker.
Engineering & Build:
- Update the build toolchain to Go
1.26.5, exporter-toolkitv0.17.1, and prometheus/commonv0.70.0. - Add regular CI checks for module tidy, generated configuration, race tests, and six-platform cross-builds. The
make confoutput must matchconfig/*.yml. - Remove the
docker/scripts andmake docker-release. Use GoReleaser to build multi-architecture release images. - Remove assumptions about specific collectors from configuration coverage tests. This makes smaller custom bundles easier to maintain.
Upgrade Notes:
- A non-canonical telemetry path, such as
//metrics, now prevents startup. Previously, the process started but the metrics endpoint was unreachable. - Update automation that parses the
versionlabel ofpg_exporter_build_infoor the--versionoutput to accept thevprefix. - If any collector uses
HISTOGRAM, do not useleas a constant label.
Checksums
https://github.com/pgsty/pg_exporter/releases/download/v1.4.0/checksums.txt
https://github.com/pgsty/pg_exporter/releases/tag/v1.4.0
v1.3.0
v1.3.0 adds PostgreSQL 19 support.
It also updates the default collectors, build toolchain, and configuration coverage tests.
Highlights:
- Default support range extended from PostgreSQL 10-18+ to 10-19+
- Default config bundle includes 57
config/*.ymldefinition files - Build dependencies updated to Go
1.26.4,lib/pq v1.12.3, Prometheus clientv1.23.2, and exporter-toolkitv0.16.0 pg_recovery_state: collectpg_stat_recoveryon recovery nodes, exposing promotion trigger status, replay LSN, timeline, recovery transaction time, and pause statepg_lock_stat: collect PG19pg_stat_lock, exposing waits, wait time, and fast-path overflow counts bylocktypepg_vacuum_score: collect the current-database summary frompg_stat_autovacuum_scores, exposing max autovacuum score and candidate table countpg_wal_19: exposewal_fpi_byteson PG19 aspg_wal_fpi_bytespg_sub_19: adapt sequence sync and logical replication conflict stats frompg_stat_subscription_stats, while keepingsync_error_countfor legacy dashboardspg_recv: recognize the PG13+ WAL receiverconnectingstate on PG19pg_slot: recognize the PG19 replication slot invalidation reasonidle_timeoutpg_db_confl: switch to an explicit column list to avoid accidentally exporting future view columnspg_backup,pg_vacuuming, andpg_clusteringcontinue reusing stable existing branches instead of changing the metric surface for low-value PG19 fields
Checksums
https://github.com/pgsty/pg_exporter/releases/download/v1.3.0/checksums.txt
https://github.com/pgsty/pg_exporter/releases/tag/v1.3.0
v1.2.2
v1.2.2 updates the release toolchain to Go 1.26.2.
This maintenance release has no changes to collectors, configuration behavior, or runtime behavior.
Highlights
- Refresh the release toolchain: bump release builds to Go
1.26.2 - No functional changes: collector behavior, default configs, metric definitions, and runtime semantics remain unchanged
Checksums
https://github.com/pgsty/pg_exporter/releases/download/v1.2.2/checksums.txt
https://github.com/pgsty/pg_exporter/releases/tag/v1.2.2
v1.2.1
v1.2.1 is a maintenance release for release engineering, configuration package consistency, documentation, and metadata.
It has no changes to collector or runtime behavior.
Highlights
- Refresh the build toolchain: bump both release workflows and Docker build images to Go
1.26.1 - Standardize config style: switch inline
descriptionvalues in both current and legacy configs to double-quoted form, and regenerate mergedpg_exporter.yml/legacy/pg_exporter.yml - Add config consistency tests: verify split and merged configs remain equivalent, and check inline metric description style to reduce configuration drift
- Refresh packaging metadata: update RPM / DEB support descriptions to PostgreSQL
9.x - 18+and pgBouncer1.8 - 1.25+, and refresh Pigsty documentation links
Checksums
https://github.com/pgsty/pg_exporter/releases/tag/v1.2.1
v1.2.0
v1.2.0 improves stability and compatibility for startup, hot reload, health probes, configuration validation, and legacy support.
New Features:
- Improve hot reload. Support platform-specific signals (
SIGHUP/SIGUSR1) and improvePOST /reloadto update configuration and query plans without a restart. - Use non-blocking startup. HTTP endpoints start even if the target precheck fails. This improves recovery and monitoring integration.
- Add a legacy configuration bundle for PostgreSQL 9.1-9.6. Use
legacy/and themake conf9target to configure monitoring for EOL versions. - Use cached health snapshots with periodic probes. This improves consistency for role-based health endpoints and reloads.
- Add
go testandgo vetto release workflows. Update the build toolchain to Go 1.26.0.
Bug Fixes:
- Fix configuration parsing cases. Reject malformed metric entries, return explicit errors if a configuration directory has no valid YAML, and improve runtime fallbacks.
- Fix CLI boolean parsing for arguments such as
--flag=false. - Fix
/explainoutput with corrected content types and safer template rendering. - Improve predicate queries and PG URL handling. Improve BOOL/BOOLEAN support, row resource handling, and
dbnamequery-parameter parsing and redaction. - Close connections asynchronously when auto-discovery removes a target.
- Fix metric and label validation. Check constant-label conflicts, scaled default values, and Prometheus naming rules.
Checksums
https://github.com/pgsty/pg_exporter/releases/tag/v1.2.0
v1.1.2
This minor release fixes the pg_timeline configuration and builds with the latest Go dependencies.
Checksums
https://github.com/pgsty/pg_exporter/releases/download/v1.1.2/checksums.txt
https://github.com/pgsty/pg_exporter/releases/tag/v1.1.2
v1.1.1
Minor release with new collectors and bug fixes.
New Features:
- New
pg_timelinecollector for timeline monitoring - New
pg_sub_16collector branch to exclude parallel operations in subscriptions (PostgreSQL 16+ compatibility)
Bug Fixes:
- Fix: Add coalesce for slotname in
pg_recvcollector to handle NULL values
Checksums
https://github.com/pgsty/pg_exporter/releases/download/v1.1.1/checksums.txt
https://github.com/pgsty/pg_exporter/releases/tag/v1.1.1
v1.1.0
Build with Go 1.25.5 and latest dependencies, collector updates:
Collector Changes:
pg_setting: update PG10-18 compatibility and addmissing_oksupport.- Add 13 new metrics:
max_parallel_workers,max_parallel_workers_per_gather,max_parallel_maintenance_workers,shared_buffers,maintenance_work_mem,effective_cache_size,fsync,full_page_writes,autovacuum,autovacuum_max_workers,checkpoint_timeout,checkpoint_completion_target,hot_standby,synchronous_commit,io_method. - Rename
work_memory_sizetowork_mem. - Change min_version from 9.6 to 10. Use explicit
::inttype conversion.
- Add 13 new metrics:
pg_size: fix log directory size detection. Checklogging_collectorinstead of matching path patterns.pg_table: replace LATERAL subqueries with JOIN to improve performance. Changetuplesandfrozenxidfrom COUNTER to GAUGE. Increase the timeout from 1s to 2s.pg_vacuuming: add a PG17 branch withindexes_total,indexes_processed, anddead_tuple_bytesto track index vacuum progress.pg_query: increase the timeout from 1s to 2s for high-load conditions.pg_io: correct thereusesdescription from “in reused” to “is reused”.pg_checkpointer: correct the pg_checkpointer_10 description from “9.4+” to “9.4-17”.pg_db_confl: correct the pg_db_confl_15 description from “9.1 - 16” to “9.1 - 15”.- Correct format alignment for
pg_db,pg_indexing,pg_clustering, andpg_backup.
Other Changes:
- Fix release year by @anayrat
Checksums
https://github.com/pgsty/pg_exporter/releases/download/v1.1.0/checksums.txt
https://github.com/pgsty/pg_exporter/releases/tag/v1.1.0
v1.0.3
- Build with Go 1.25.4 and latest dependencies
- Fix #80 Conflict with libpq env variables
- Change default value of
auto-discoverytotrueby @kadaffy
Checksums
https://github.com/pgsty/pg_exporter/releases/download/v1.0.3/checksums.txt
https://github.com/pgsty/pg_exporter/releases/tag/v1.0.3
v1.0.2
- Build with Go 1.25.0 and the latest dependencies.
- Add a dedicated website and homepage: https://exp.pgsty.com
- Use GoReleaser and CI/CD to release for more operating systems and architectures:
- Add Windows amd64 support.
- Add Linux ppc64le support.
Checksums
https://github.com/pgsty/pg_exporter/releases/download/v1.0.2/checksums.txt
https://github.com/pgsty/pg_exporter/releases/tag/v1.0.2
v1.0.1
- Add dockerhub images: pgsty/pg_exporter
- Update Go dependencies to the latest version. Build with Go 1.24.5
- Disable
pg_tsdb_hypertableby default because thetimescaledbcatalog has changed.
Checksums
https://github.com/pgsty/pg_exporter/releases/tag/v1.0.1
v1.0.0
Add PostgreSQL 18 metrics support
- new collector branch
pg_wal_18: - remove
write,sync,write_time,sync_timemetrics - move to
pg_stat_io - new collector branch
pg_checkpointer_18: - new metric
num_done - new metric
slru_written - new collector branch
pg_db_18: - new metric
parallel_workers_to_launch - new metric
parallel_workers_launched - new collector branch
pg_table_18: table_parallel_workers_to_launchtable_parallel_workers_launched- new collector branch
pg_io_18: - new series about WAL statistics
- new metric
read_bytes - new metric
write_bytes - new metric
extend_bytes - remove
op_bytesdue to fixed value - new collector branch
pg_vacuuming_18 - new metric
delay_time
https://github.com/pgsty/pg_exporter/releases/tag/v1.0.0
v0.9.0
Default Collectors
- new metrics collector for
timescaledbhypertable - new metrics collector for
citusdist node - new metrics collector for
pg_wait_samplingwait event profile pg_slotoverhaul: Add 16/17 pg_replication_slot metrics- allow
pg_slotcollector run on replica since 16/17 - refactor
pg_waitcollector to agg from all processes - restrict pg_clustering, pg_indexing, pg_vacuuming run on primary
- mark all
reset_timeasGAUGErather thanCOUNTER - fix
pg_recovery_prefetch_skip_fpwtype fromGAUGEtoCOUNTER - fix
pg_recv.statetype fromLABELtoGAUGE - Format collector in compact mode
- new default metric
pg_exporter_build_info/pgbouncer_exporter_build_info - add
server_encodingtopg_metacollector - add 12 new setting metrics to
pg_settingcollector
- wal_block_size
- segment_size
- wal_segment_size
- wal_level
- wal_log_hints
- work_mem
- hugepage_count
- hugepage_status
- max_wal_size
- min_wal_size
- max_slot_wal_keep_size
Exporter Codebase
- normalize collector branch name with min pg ver suffix
- Add license file to binary packages
- move
pgsty/pg_exporterrepo topgsty/pg_exporter - refactor
server.goto reduceCompatibleandPostgresPrecheckcomplexity - rename metrics collector with extra number prefix for better sorting
- bump dependencies to the latest version
- execute fatal collectors ahead of all non-fatal collectors, and fail fast
https://github.com/pgsty/pg_exporter/releases/tag/v0.9.0
v0.8.1
- Bump dependencies to the latest version
- Bump golang.org/x/net from 0.35.0 to 0.36.0 #67
- Update docker images building tags
https://github.com/pgsty/pg_exporter/releases/tag/v0.8.1
v0.8.0
- Add PgBouncer 1.24 new metrics support (stat, pool, database)
- Fix:
310-pg_size.ymlfails if log dir not set properly #64 by @Süleyman Vurucu - Build with the latest Go 1.24 and bump all dependencies
- Refactor logging with the standard
log/sloginstead ofgo-kit - Full Changelog: https://github.com/pgsty/pg_exporter/compare/v0.7.1...v0.8.0
https://github.com/pgsty/pg_exporter/releases/tag/v0.8.0
v0.7.1
Routine update with dependabot
- Feat: support specifying configuration as Reader by @ringerc in #62
- Bump golang.org/x/crypto from 0.21.0 to 0.31.0 by @dependabot in #63
- Fix some typos
- Full Changelog: https://github.com/pgsty/pg_exporter/compare/v0.7.0...v0.7.1
https://github.com/pgsty/pg_exporter/releases/tag/v0.7.1
v0.7.0
Refactor the codebase for the latest Go version.
- PostgreSQL 17 Metrics Support by @Vonng
- pg_exporter: predicate queries feature by @ringerc
- Do a clean build in the dockerfile by @ringerc by @ringerc
- pg_exporter: don’t panic after “bind: address already in use” by @ringerc
- pg_exporter: fix /stat endpoint formatting by @ringerc
- pg_exporter: omit default query properties on yaml export by @ringerc
- Exclude template DBs from discovery and schema-qualify discovery query by @ringerc
- Fix some typos and some metric description mistakes by @ringerc
- Switch from unmaintained lib/pq driver to pgx with stdlib wrapper by @ringerc
https://github.com/pgsty/pg_exporter/releases/tag/v0.7.0
v0.6.0
Fix Dependabot security issues.
Add pg16 collectors.
Add
arm64&aarch64packages.Remove the
monitorschema requirement forpg_querycollectors. Set search_path to findpg_stat_statements, or install it in the defaultpublicschema.Change the pgBouncer version parsing message level from info to debug.
Fix the missing
relidin thepg_table_10_12collector.Recognize the files with yml suffix in config directory by @Japin Li
https://github.com/pgsty/pg_exporter/releases/tag/v0.6.0
v0.5.0
Exporter Enhancement
- Build rpm & deb with
nfpm - Add
column.default, replace when metric value is NULL - Add
column.scaleto multiply float/int values by a scale factor, such as conversion from µs to seconds - Fix
/statendpoint output - Add docker container
pgsty/pg_exporter
Metrics Collector
- scale bgwriter & pg_wal time unit to second
- remove pg_class collector and move it to pg_table & pg_inex
- add pg_class metrics to pg_table
- add pg_class metrics to pg_index
- enable pg_table_size by default
- scale pg_query pg_db pg_bgwriter pg_ssl pgbouncer_stat time metrics to second
https://github.com/pgsty/pg_exporter/releases/tag/v0.5.0
v0.4.1
- Update default collectors:
- Exclude citus & timescaledb schemas from object monitoring.
- Prevent duplicate pg_statio tuples.
- Support pgBouncer v1.16.
- Fix overlapping
pg_replcollectors on pg 12.
- Add the
-Tconnect-timeoutPG_EXPORTER_CONNECT_TIMEOUTparameter for remote PostgreSQL monitoring. - Rename
pg_exporter.yamltopg_exporter.ymlin the RPM package.
https://github.com/pgsty/pg_exporter/releases/tag/v0.4.1
v0.4.0
- Add PG 14 support
- Update the default metrics configuration. The old configuration remains supported
- add
auto-discovery,include-databaseandexclude-databaseoption - Add multiple database monitoring implementations (with
auto-discovery = on)
https://github.com/pgsty/pg_exporter/releases/tag/v0.4.0
v0.3.2
- fix shadow DSN corner case
- fix typo & docs
https://github.com/pgsty/pg_exporter/releases/tag/v0.3.2
v0.3.1
Fix default configuration errors, particularly for versions before 13.
- Account for the
primary_conninfosetting being available only from PG13. - Add the
funcidlabel topg_functo prevent duplicate labels from function names. - Fix the version string to
pg_exporter.
https://github.com/pgsty/pg_exporter/releases/tag/v0.3.1
v0.3.0
https://github.com/pgsty/pg_exporter/releases/tag/v0.3.0
- Update the default configuration to support PostgreSQL 13 metrics, including
pg_slru,pg_shmem,pg_query13, andpg_backup. - Add REST APIs for health and recovery status checks.
- Add a dummy server that returns
pg_up 0before PgExporter initialization. - Add
sslmode=disableto the URL ifsslmodeis absent. - Fix typos and bugs.
v0.2.0
- add yum package and linux service definition
- add a ‘skip’ flag into query config
- fix
pgbouncer_upmetrics - add conf reload support
https://github.com/pgsty/pg_exporter/releases/tag/v0.2.0
v0.1.2
- fix pgbouncer_up metrics
- add dynamic configuration reload
- remove ‘shard’ related logic
- add a ‘bulky’ mode to default settings
https://github.com/pgsty/pg_exporter/releases/tag/v0.1.2
v0.1.1
Fix a startup hang that occurs if any query fails.
https://github.com/pgsty/pg_exporter/releases/tag/v0.1.1
v0.1.0
This is the first stable release.
https://github.com/pgsty/pg_exporter/releases/tag/v0.1.0
v0.0.4
This release passed production tests on 200+ nodes for about 2 weeks.
https://github.com/pgsty/pg_exporter/releases/tag/v0.0.4
v0.0.3
v0.0.3 passed production tests.
This version is already tested in a production environment.
The project changes rapidly. Use this version with caution in production.
https://github.com/pgsty/pg_exporter/releases/tag/v0.0.3
v0.0.2
This version is ready for testing.
https://github.com/pgsty/pg_exporter/releases/tag/v0.0.2
v0.0.1
Add pgBouncer mode