PostgreSQL Health Metrics Reference
Exported PostgreSQL health metrics, grouped by source, with types, labels, and interpretation.
Use this reference with PostgreSQL Database Monitoring for prerequisites, permissions, configuration, and troubleshooting.
Amazon Aurora PostgreSQL writers and read replicas are supported. Enabled, applicable queries are attempted on each scrape; known Aurora restrictions produce warning events without failing the scrape. Metrics from supported queries continue collecting. See Aurora PostgreSQL limitations for affected queries, metric availability, and diagnostic events.
Every suffix below is prefixed with groundcover_db_pg_. For example, connections is exported as groundcover_db_pg_connections. Metrics include server_address, server_port, integration labels such as gc_integration_name, and configured extra labels. Group-specific labels are described below; avoid extra labels that overwrite these dimensions.
Counters are raw cumulative database counters: use rate() or increase() to measure activity over time and handle resets. Gauges describe the current observation. A missing series can mean a disabled group, missing capability/permission, filtering, top-N selection, or an empty source. It does not imply zero. See collection diagnostics.
Connections
pg_stat_activity and max_connections; labels: db_namespace and state. Waits of type Client, Activity, and Timeout retain the session-state bucket.
connections
Gauge; connections
Current connections; PostgreSQL excludes the collector application from this count.
max_connections
Gauge; connections
Configured connection limit.
Replication
pg_stat_replication and pg_replication_slots; primary only. Labels include replica, replication_slot, and active. No replica/slot rows means no corresponding series.
replication_lag_seconds
Gauge; seconds
Write, flush, or replay lag reported for a replica. phase: write, flush, replay.
replication_lag_bytes
Gauge; bytes
Current WAL position minus the replica replay position.
replication_slot_retained_bytes
Gauge; bytes
WAL bytes retained behind a slot restart position.
replication_slot_xmin_age
Gauge; transaction IDs
Transaction ID age of the slot xmin; omitted when unavailable.
Standby
Recovery-only queries using replay functions and pg_stat_wal_receiver. Receiver details require immediately usable pg_monitor privileges.
replication_replay_lag_seconds
Gauge; seconds
Time since the last replayed transaction; zero when receive and replay positions match. Omitted before a replay timestamp exists.
wal_receiver_connected
Gauge; 0 or 1
1 when a WAL receiver is streaming, otherwise 0.
wal_receiver_message_age_seconds
Gauge; seconds
Age of the last received or sent receiver message. kind: receipt, send.
wal_receiver_timeline_id
Gauge; timeline ID
Timeline reported by the streaming WAL receiver.
Database stats
pg_stat_database; db_namespace identifies the database. Timing, checksum, and session fields depend on settings and server capabilities.
deadlocks_total
Counter; deadlocks
Detected deadlocks.
transactions_total
Counter; transactions
Committed or rolled-back transactions. outcome: commit, rollback.
blocks_total
Counter; blocks
Database blocks read from storage or found in the PostgreSQL buffer cache. op: hit, read.
rows_total
Counter; rows
Rows returned, fetched, inserted, updated, or deleted. op: returned, fetched, inserted, updated, deleted.
temp_files_total
Counter; files
Temporary files created.
temp_bytes_total
Counter; bytes
Bytes written to temporary files.
checksum_failures_total
Counter; failures
Detected checksum failures; omitted when checksum statistics are unavailable.
checksums_enabled
Gauge; 0 or 1
1 when the checksum-failure statistic is available, otherwise 0.
io_seconds_total
Counter; seconds
Database block read/write time; requires track_io_timing. op: read, write.
sessions_total
Counter; sessions
Sessions established.
sessions_terminated_total
Counter; sessions
Sessions terminated by abandonment, fatal error, or termination. reason: abandoned, fatal, killed.
session_seconds_total
Counter; seconds
Total, active, or idle-in-transaction session time. kind: total, active, idle_in_transaction.
Transaction wraparound
pg_database; db_namespace identifies the database.
wraparound_headroom_ratio
Gauge; ratio
1 minus age(datfrozenxid) divided by 2147483648. Lower values mean less transaction ID headroom; this is not an autovacuum threshold.
Database size
pg_database_size; db_namespace identifies each non-template, non-excluded database.
database_size_bytes
Gauge; bytes
Total database size on disk.
Conflicts
pg_stat_database_conflicts; db_namespace identifies the database.
recovery_conflicts_total
Counter; conflicts
Recovery conflicts by reason. Zero counters are valid, including on a primary. reason: bufferpin, deadlock, lock, snapshot, tablespace.
Checkpoints
pg_stat_checkpointer and/or pg_stat_bgwriter, selected from server capabilities. Backend write/fsync counters are absent when their source columns are unavailable.
checkpoints_total
Counter; checkpoints
Timed or requested checkpoints. kind: timed, requested.
checkpoint_seconds_total
Counter; seconds
Time spent writing or syncing checkpoints. op: write, sync.
buffers_written_total
Counter; buffers
Buffers written by the checkpointer, background writer, or backends, where exposed. source: checkpoint, bgwriter, backend.
buffers_backend_fsync_total
Counter; operations
Backend fsync operations, where exposed.
bgwriter_maxwritten_stops_total
Counter; stops
Times the background writer stopped because it reached its write limit.
buffers_allocated_total
Counter; buffers
Buffers allocated.
WAL
pg_stat_wal, when supported. WAL I/O fields may be unavailable even when WAL generation counters are collected.
wal_records_total
Counter; records
WAL records generated.
wal_bytes_total
Counter; bytes
WAL bytes generated.
wal_fpi_total
Counter; images
Full-page images generated.
wal_buffers_full_total
Counter; occurrences
Times WAL buffers filled.
wal_io_total
Counter; operations
WAL write or sync operations, where exposed. op: write, sync.
wal_io_seconds_total
Counter; seconds
WAL write or sync time; requires track_wal_io_timing and the corresponding source columns. op: write, sync.
WAL archiver
pg_stat_archiver. Counters can remain zero when archiving is inactive.
wal_archived_total
Counter; files
Successfully archived WAL files.
wal_archive_failed_total
Counter; attempts
Failed WAL archival attempts.
I/O
pg_stat_io, when supported. Labels: backend_type, context, object, and op.
io_ops_total
Counter; operations
I/O operations by backend type, context, object, and operation. op: read, write, extend, fsync, hit, eviction.
io_op_seconds_total
Counter; seconds
I/O operation time; requires track_io_timing. op: read, write, extend, fsync.
Instance
Server start time, pg_control_checkpoint(), WAL position functions, and pg_ls_waldir(). Control-data/filesystem queries require access to those functions.
uptime_seconds
Gauge; seconds
Time since PostgreSQL started.
checkpoint_delay_seconds
Gauge; seconds
Time since the checkpoint recorded in control data.
checkpoint_delay_bytes
Gauge; bytes
WAL distance from the checkpoint position.
redo_delay_bytes
Gauge; bytes
WAL distance from the checkpoint redo position.
timeline_id
Gauge; timeline ID
Timeline in checkpoint control data.
wal_files
Gauge; files
Number of files returned by pg_ls_waldir().
wal_dir_bytes
Gauge; bytes
Combined size of files returned by pg_ls_waldir().
wal_oldest_file_age_seconds
Gauge; seconds
Age of the oldest WAL-directory file modification time.
Locks
pg_locks, pg_database, and pg_stat_activity; requires immediately usable pg_monitor. Labels include db_namespace, mode, and granted.
locks
Gauge; locks
Locks by mode and granted state. Missing observed combinations are emitted as zero.
lock_idle_in_transaction_age_seconds
Gauge; seconds
Age of the oldest idle-in-transaction session holding an ExclusiveLock or AccessExclusiveLock other than transaction/virtual transaction locks. Empty when none qualifies.
Tables
pg_stat_user_tables and relation-size functions in each eligible database. Labels: db_namespace and db_collection_name (schema.table). Collection requires CONNECT and is bounded by the table topN.
table_rows
Gauge; rows
Estimated live/dead tuples. kind: live, dead.
table_scans_total
Counter; scans
Sequential or index scans of the selected table. kind: seq, idx.
table_tuples_total
Counter; tuples
Inserted, updated, deleted, or HOT-updated tuples. op: inserted, updated, deleted, hot_updated.
table_size_bytes
Gauge; bytes
Heap, total relation, or combined index size for the table. kind: heap, total, indexes.
table_last_vacuum_age_seconds
Gauge; seconds
Age since vacuum, autovacuum, analyze, or autoanalyze. Unknown timestamps omit that series; they do not become zero. kind: vacuum, autovacuum, analyze, autoanalyze.
table_vacuum_total
Counter; runs
Vacuum, autovacuum, analyze, or autoanalyze runs. kind: vacuum, autovacuum, analyze, autoanalyze.
Indexes
pg_stat_user_indexes, pg_class, and pg_index in each eligible database. Labels: db_namespace, db_collection_name (schema.table), and index; index_info also has unique, valid, and primary. Independently bounded by index topN.
index_scans_total
Counter; scans
Scans initiated on the selected index.
index_size_bytes
Gauge; bytes
Index size on disk.
index_info
Gauge; constant 1
Constant 1 with unique, valid, and primary metadata labels. Join with index statistics using database, table, and index identity.
Autovacuum
Instance settings and pg_stat_activity. The running-worker series requires immediately usable pg_monitor; settings collection is independent of that worker query.
autovacuum_workers
Gauge; workers
Configured maximum or currently running autovacuum workers. Manual VACUUM sessions are excluded. kind: max, running.
autovacuum_enabled
Gauge; 0 or 1
1 when the instance autovacuum setting is on, otherwise 0. This does not describe table-specific overrides.
Additional instance metrics
groundcover_db_pg_is_in_recovery
Gauge
1 on a standby, 0 on a primary; emitted when Replication or Standby is enabled.
groundcover_db_pg_statements_evicted_total
Counter
pg_stat_statements_info.dealloc; emitted by statement collection when the info view is available. Increasing values indicate statement entries are being evicted.
Query examples
Replace <integration-name> with the integration name. Choose a rate window spanning several scrapes.
Transaction rate:
Buffer-cache hit ratio, derived from counters (not an independently exported metric). A database with no block activity has an undefined ratio:
Estimated dead tuples for the selected tables:
Last updated
