Skip to main content

Metrics Reference

pgX provides the most comprehensive PostgreSQL monitoring available. From server health to query performance, replication lag to lock contention — every metric you need to understand, optimize, and troubleshoot your PostgreSQL clusters is at your fingertips.

Below is the complete reference of all metrics you can collect and use.


Table of Contents​

  1. Service Health & Connection
  2. Server Metadata & Version
  3. Checkpoint & Recovery
  4. WAL (Write-Ahead Log)
  5. Background Writer
  6. Database Statistics
  7. Backend & Connection Details
  8. Table Metrics
  9. Index Metrics
  10. Sequence Metrics
  11. Function Metrics
  12. System Metrics
  13. Replication - Outgoing
  14. Replication - Slots
  15. Replication - Incoming
  16. Query Statement Statistics
  17. Role Metrics
  18. Tablespace Metrics
  19. Lock Metrics
  20. Extension Metrics
  21. Configuration Settings
  22. Progress Metrics
  23. Logical Replication - Publications
  24. Logical Replication - Subscriptions
  25. Cluster Metadata

1. Service Health & Connection​

Metric NameDescriptionTypeLabels
pg_up1 if PostgreSQL is up, 0 if downGauge-

2. Server Metadata & Version​

Metric NameDescriptionTypeLabels
pg_metadataPostgreSQL metadata informationGaugekey, value
pg_system_identifierPostgreSQL system identifierGaugeidentifier
pg_server_versionPostgreSQL server version (e.g., 14.0)Gaugeversion
pg_server_start_time_secondsPostgreSQL server start time as unix timestampGauge-
pg_conf_load_time_secondsPostgreSQL configuration load time as unix timestampGauge-

3. Checkpoint & Recovery​

Metric NameDescriptionTypeLabels
pg_checkpoint_infoPostgreSQL checkpoint informationGaugemetric
pg_recovery_statusPostgreSQL recovery statusGaugemetric

pg_checkpoint_info Sub-metrics​

Sub-metricDescription
checkpoint_lsnCheckpoint LSN position
redo_lsnRedo LSN position
timeline_idCurrent timeline ID
next_xidNext transaction ID
oldest_xidOldest active transaction ID
oldest_active_xidOldest currently active transaction ID
checkpoint_timeTime of last checkpoint
wal_flush_lsnWAL flush LSN position
wal_insert_lsnWAL insert LSN position
wal_lsnCurrent WAL LSN position

pg_recovery_status Sub-metrics​

Sub-metricDescription
is_in_recovery1 if server is in recovery mode
is_wal_replay_paused1 if WAL replay is paused

4. WAL (Write-Ahead Log)​

Metric NameDescriptionTypeLabelsNotes
pg_walPostgreSQL WAL statisticsCountermetricPostgreSQL 14+
pg_wal_archivingPostgreSQL WAL archiving statisticsCountermetric
pg_wal_filesPostgreSQL WAL file countsGaugetype
pg_highest_wal_segmentNumerically highest WAL segmentGauge-

pg_wal Sub-metrics (PostgreSQL 14+)​

Sub-metricDescription
recordsNumber of WAL records generated
fpiNumber of full page images generated
bytesTotal bytes of WAL generated
buffers_fullNumber of times WAL buffers became full
writeNumber of times WAL buffers were written
syncNumber of times WAL files were synced
write_time_msTotal time spent writing WAL buffers
sync_time_msTotal time spent syncing WAL files

pg_wal_archiving Sub-metrics​

Sub-metricDescription
archived_countNumber of WAL files successfully archived
failed_countNumber of failed WAL archive attempts
last_archived_timeTimestamp of last successful archive
last_failed_timeTimestamp of last failed archive
stats_resetStatistics reset timestamp

pg_wal_files Sub-metrics​

Sub-metricDescription
countTotal number of WAL files
ready_countNumber of WAL files ready for archiving

5. Background Writer​

Metric NameDescriptionTypeLabels
pg_bgwriterPostgreSQL background writer statisticsCountermetric

pg_bgwriter Sub-metrics​

Sub-metricDescription
checkpoints_timedNumber of scheduled checkpoints
checkpoints_reqNumber of requested checkpoints
checkpoint_write_time_msTime spent writing checkpoint files
checkpoint_sync_time_msTime spent syncing checkpoint files
buffers_checkpointBuffers written during checkpoints
buffers_cleanBuffers written by background writer
buffers_backendBuffers written directly by backends
buffers_backend_fsyncBackend fsync calls
buffers_allocBuffers allocated

6. Database Statistics​

Metric NameDescriptionTypeLabels
pg_connectionsPostgreSQL connection statisticsGaugestate, database, user
pg_database_infoDatabase information including ownerGaugedatabase, owner
pg_database_size_bytesDatabase size in bytesGaugedatabase
pg_database_statsDatabase statistics (counters)Counterdatabase, metric
pg_database_gauge_statsDatabase statistics (gauges)Gaugedatabase, metric

pg_database_stats Sub-metrics​

Sub-metricDescriptionNotes
num_backendsNumber of connected backends
xact_commitTransactions committed
xact_rollbackTransactions rolled back
blks_readDisk blocks read
blks_hitBuffer cache hits
tup_returnedRows returned by queries
tup_fetchedRows fetched by queries
tup_insertedRows inserted
tup_updatedRows updated
tup_deletedRows deleted
temp_filesTemporary files created
temp_bytesTemporary file bytes written
deadlocksNumber of deadlocks detected
conflictsQueries canceled due to conflicts
blk_read_time_msTime spent reading blocks
blk_write_time_msTime spent writing blocks
stats_resetStatistics reset timestamp
checksum_failuresData page checksum failuresPG12+
checksum_last_failureLast checksum failure timestampPG12+
session_time_msTotal session timePG14+
active_time_msTime spent executing queriesPG14+
idle_in_transaction_time_msTime spent idle in transactionPG14+
sessionsTotal sessionsPG14+
sessions_abandonedAbandoned sessionsPG14+
sessions_fatalSessions terminated by fatal errorsPG14+
sessions_killedSessions terminated by operatorPG14+

pg_database_gauge_stats Sub-metrics​

Sub-metricDescription
connection_limitMaximum allowed connections
age_datfrozenxidAge of oldest frozen transaction ID

7. Backend & Connection Details​

Metric NameDescriptionTypeLabels
pg_backend_type_countCount of PostgreSQL backends by typeGaugetype
pg_backend_wait_eventsCount of backends by wait eventGaugewait_event_type, wait_event
pg_backend_age_secondsBackend connection/transaction/query ageGaugepid, database, user, application, state, metric
pg_backend_infoPostgreSQL backend information with query textGaugepid, database, user, application, client, state, query, queryid

pg_backend_age_seconds Sub-metrics​

Sub-metricDescription
backend_ageAge of the backend connection
transaction_ageAge of the current transaction
query_ageAge of the current query
state_ageTime in current state

8. Table Metrics​

Metric NameDescriptionTypeLabels
pg_table_infoTable metadata informationGaugedatabase, schema, table, relkind, relpersistence, tablespace, parent, is_partition
pg_table_statsTable statisticsGaugedatabase, schema, table, metric

pg_table_stats Sub-metrics​

Sub-metricDescriptionNotes
size_bytesTable size in bytes
seq_scanSequential scans initiated
seq_tup_readRows fetched by sequential scans
idx_scanIndex scans initiated
idx_tup_fetchRows fetched by index scans
n_tup_insRows inserted
n_tup_updRows updated
n_tup_delRows deleted
n_tup_hot_updHOT updates (no index update needed)
n_live_tupEstimated live rows
n_dead_tupEstimated dead rows
vacuum_countManual vacuum count
autovacuum_countAutovacuum count
analyze_countManual analyze count
autoanalyze_countAutoanalyze count
heap_blks_readHeap blocks read from disk
heap_blks_hitHeap blocks found in cache
idx_blks_readIndex blocks read from disk
idx_blks_hitIndex blocks found in cache
toast_blks_readTOAST blocks read from disk
toast_blks_hitTOAST blocks found in cache
tidx_blks_readTOAST index blocks read
tidx_blks_hitTOAST index blocks in cache
bloat_bytesEstimated table bloat in bytes
last_vacuumLast manual vacuum timestamp
last_autovacuumLast autovacuum timestamp
last_analyzeLast manual analyze timestamp
last_autoanalyzeLast autoanalyze timestamp
n_mod_since_analyzeRows modified since last analyze
age_relfrozenxidAge of table's frozen XID
num_columnsNumber of columns in table
n_ins_since_vacuumRows inserted since last vacuumPG13+

9. Index Metrics​

Metric NameDescriptionTypeLabels
pg_index_infoIndex metadata informationGaugedatabase, schema, table, index, am_name, tablespace, definition
pg_index_statsIndex statisticsGaugedatabase, schema, table, index, metric
pg_index_extended_infoExtended index metadataGaugeschema, table, index, is_unique, is_primary, is_partial, partial_condition
pg_column_statsColumn statistics for index analysisGaugeschema, table, column, metric

pg_index_stats Sub-metrics​

Sub-metricDescriptionNotes
oidIndex OID
table_oidParent table OID
size_bytesIndex size in bytes
idx_scanIndex scans initiated
idx_tup_readIndex entries read
idx_tup_fetchTable rows fetched
idx_blks_readIndex blocks read from disk
idx_blks_hitIndex blocks found in cache
bloat_bytesEstimated index bloat in bytes
num_columnsNumber of columns in index
last_idx_scanLast index scan timestampPG16+

pg_column_stats Sub-metrics​

Sub-metricDescription
n_distinctEstimated number of distinct values
correlationPhysical row ordering correlation
null_fracFraction of null values

10. Sequence Metrics​

Metric NameDescriptionTypeLabels
pg_sequence_statsSequence statisticsCounterdatabase, schema, sequence, metric

pg_sequence_stats Sub-metrics​

Sub-metricDescription
blks_readBlocks read from disk
blks_hitBlocks found in cache

11. Function Metrics​

Metric NameDescriptionTypeLabels
pg_function_statsUser function statisticsCounterdatabase, schema, function, metric
pg_function_gauge_statsUser function gauge statisticsGaugedatabase, schema, function, metric

pg_function_stats Sub-metrics​

Sub-metricDescription
callsNumber of function calls
total_time_msTotal time spent in function
self_time_msSelf time (excluding called functions)

pg_function_gauge_stats Sub-metrics​

Sub-metricDescription
avg_time_msAverage time per call

12. System Metrics​

Metric NameDescriptionTypeLabels
pg_system_infoSystem informationGaugecpu_model, hostname, num_cores
pg_system_load_avgSystem load average (1-minute)Gauge-
pg_system_memory_bytesSystem memory usageGaugetype
pg_system_swap_bytesSystem swap usageGaugetype

pg_system_memory_bytes Types​

TypeDescription
usedUsed memory
freeFree memory
buffersBuffer memory
cachedCached memory
slabSlab memory

pg_system_swap_bytes Types​

TypeDescription
usedUsed swap
freeFree swap

13. Replication - Outgoing​

Metric NameDescriptionTypeLabels
pg_replication_outgoingPostgreSQL outgoing replication statisticsGaugeclient_addr, usename, application_name, state, sync_state, metric
pg_replication_lag_millisecondsPostgreSQL replication lag in millisecondsGaugeclient_addr, usename, application_name, lag_type
pg_replication_outgoing_infoPostgreSQL outgoing replication connection infoGaugeclient_addr, usename, application_name, pid, backend_xmin, sync_priority

pg_replication_outgoing Sub-metrics​

Sub-metricDescriptionNotes
sent_lsnLSN position sent to standby
write_lsnLSN position written by standby
flush_lsnLSN position flushed by standby
replay_lsnLSN position replayed by standby
backend_start_timeBackend start timestamp
reply_timeLast reply timestampPG12+

pg_replication_lag_milliseconds Lag Types​

Lag TypeDescription
writeWrite lag
flushFlush lag
replayReplay lag

14. Replication - Slots​

Metric NameDescriptionTypeLabels
pg_replication_slot_infoPostgreSQL replication slot informationGaugeslot_name, slot_type, database, active, plugin, temporary, wal_status, two_phase, conflicting
pg_replication_slot_detailPostgreSQL replication slot detailed metricsGaugeslot_name, slot_type, metric
pg_replication_slot_lsnPostgreSQL replication slot LSN valuesGaugeslot_name, lsn_type
pg_replication_slot_lag_bytesPostgreSQL replication slot lag in bytesGaugeslot_name

pg_replication_slot_detail Sub-metrics​

Sub-metricDescriptionNotes
xminOldest transaction needed by slot
catalog_xminOldest transaction affecting system catalogs
safe_wal_size_bytesSafe WAL size for slotPG13+

pg_replication_slot_lsn LSN Types​

LSN TypeDescription
restartRestart LSN position
confirmed_flushConfirmed flush LSN position

15. Replication - Incoming​

Metric NameDescriptionTypeLabels
pg_replication_incomingPostgreSQL incoming replication statisticsGaugestatus, sender_host, slot_name, metric

pg_replication_incoming Sub-metrics​

Sub-metricDescription
received_lsnLSN position received
latest_end_lsnLatest end LSN
lag_bytesReplication lag in bytes
seconds_since_last_messageSeconds since last message from primary

16. Query Statement Statistics​

Metric NameDescriptionTypeLabels
pg_statement_statsPostgreSQL statement statisticsCounterdatabase, user, query, queryid, metric

pg_statement_stats Sub-metrics​

Sub-metricDescriptionNotes
callsNumber of query executions
total_time_msTotal execution time
rowsTotal rows affected/returned
max_time_msMaximum execution time
min_time_msMinimum execution time
avg_time_msAverage execution time
stddev_time_msStandard deviation of execution time
shared_blks_hitShared buffer cache hits
shared_blks_readShared blocks read from disk
shared_blks_dirtiedShared blocks dirtied
shared_blks_writtenShared blocks written
local_blks_hitLocal buffer cache hits
local_blks_readLocal blocks read
local_blks_dirtiedLocal blocks dirtied
local_blks_writtenLocal blocks written
temp_blks_readTemp blocks read
temp_blks_writtenTemp blocks written
blk_read_time_msBlock read time
blk_write_time_msBlock write time
plansNumber of times plannedPG13+
total_plan_time_msTotal planning timePG13+
min_plan_time_msMinimum planning timePG13+
max_plan_time_msMaximum planning timePG13+
stddev_plan_time_msStandard deviation of planning timePG13+

17. Role Metrics​

Metric NameDescriptionTypeLabels
pg_role_infoPostgreSQL role informationGaugename, attribute

pg_role_info Attributes​

AttributeDescription
superuser1 if superuser
inherit1 if inherits privileges
createrole1 if can create roles
createdb1 if can create databases
canlogin1 if can login
replication1 if can initiate replication
bypassrls1 if bypasses row-level security
connlimitConnection limit (-1 for no limit)

18. Tablespace Metrics​

Metric NameDescriptionTypeLabels
pg_tablespace_size_bytesTablespace size in bytesGaugename, owner, location
pg_tablespace_usageTablespace disk and inode usageGaugename, metric

pg_tablespace_usage Sub-metrics​

Sub-metricDescription
disk_usedDisk space used
disk_totalTotal disk space
inodes_usedInodes used
inodes_totalTotal inodes

19. Lock Metrics​

Metric NameDescriptionTypeLabels
pg_locks_countCount of PostgreSQL locks by type and modeGaugelocktype, mode, granted
pg_lock_detailDetailed PostgreSQL lock information per PIDGaugepid, database, locktype, mode, granted, relation_oid, wait_start
pg_blocking_pidsWhich PIDs are blocking which other PIDsGaugeblocked_pid, blocking_pid

20. Extension Metrics​

Metric NameDescriptionTypeLabels
pg_extension_infoPostgreSQL extension informationGaugename, db_name, schema_name, default_version, installed_version

21. Configuration Settings​

Metric NameDescriptionTypeLabels
pg_settingsPostgreSQL configuration settingsGaugename, value, source

Tracked Settings​

SettingDescription
max_connectionsMaximum number of connections
shared_buffersShared buffer size
work_memWork memory per operation
maintenance_work_memMaintenance work memory
effective_cache_sizeEffective cache size
max_wal_sizeMaximum WAL size
min_wal_sizeMinimum WAL size
max_worker_processesMaximum worker processes
max_parallel_workersMaximum parallel workers
max_parallel_workers_per_gatherMax parallel workers per gather
autovacuumAutovacuum enabled
synchronous_commitSynchronous commit mode
checkpoint_timeoutCheckpoint timeout
wal_levelWAL level
max_locks_per_transactionMax locks per transaction
deadlock_timeoutDeadlock timeout

22. Progress Metrics​

Metric NameDescriptionTypeLabels
pg_vacuum_progressPostgreSQL vacuum progress informationGaugedatabase, table, phase, pid, metric
pg_analyze_progressPostgreSQL ANALYZE progressGaugedatabase, table, phase, pid, metric
pg_cluster_progressPostgreSQL CLUSTER progressGaugedatabase, table, phase, pid, metric
pg_create_index_progressPostgreSQL CREATE INDEX progressGaugedatabase, index, phase, pid, metric
pg_recovery_detailPostgreSQL recovery detail metricsGaugemetric

pg_vacuum_progress Sub-metrics​

Sub-metricDescription
heap_blks_totalTotal heap blocks
heap_blks_scannedHeap blocks scanned
heap_blks_vacuumedHeap blocks vacuumed
index_vacuum_countIndex vacuum count
num_dead_tuplesNumber of dead tuples
max_dead_tuplesMaximum dead tuples

pg_analyze_progress Sub-metrics​

Sub-metricDescription
sample_blks_totalTotal sample blocks
sample_blks_scannedSample blocks scanned

pg_cluster_progress Sub-metrics​

Sub-metricDescription
heap_blks_totalTotal heap blocks
heap_blks_scannedHeap blocks scanned

pg_create_index_progress Sub-metrics​

Sub-metricDescription
blocks_totalTotal blocks
blocks_doneBlocks completed
tuples_totalTotal tuples
tuples_doneTuples completed

pg_recovery_detail Sub-metrics​

Sub-metricDescription
last_wal_receive_lsnLast WAL receive LSN
last_wal_replay_lsnLast WAL replay LSN
last_xact_replay_timestampLast transaction replay timestamp

23. Logical Replication - Publications​

Metric NameDescriptionTypeLabels
pg_publication_infoPostgreSQL publication informationGaugedatabase, publication, all_tables, insert, update, delete
pg_publication_table_countNumber of tables in publicationGaugedatabase, publication

24. Logical Replication - Subscriptions​

Metric NameDescriptionTypeLabels
pg_subscription_infoPostgreSQL subscription informationGaugedatabase, subscription, enabled
pg_subscription_statsPostgreSQL subscription statisticsGauge/Counterdatabase, subscription, metric

pg_subscription_stats Sub-metrics​

Sub-metricDescriptionNotes
pub_countNumber of publications
table_countNumber of subscribed tables
worker_countNumber of workers
received_lsnReceived LSN position
latest_end_lsnLatest end LSN
latency_microsecondsReplication latency
apply_error_countApply error countPG15+
sync_error_countSync error countPG15+

25. Cluster Metadata​

Metric NameDescriptionTypeLabels
pg_notification_queue_usageFraction of async notification queue usedGauge-
pg_last_xactLast committed transaction informationGaugemetric
pg_prior_lsnPrevious checkpoint LSNGauge-

pg_last_xact Sub-metrics​

Sub-metricDescription
xidLast transaction ID
timestampLast transaction timestamp

Note: pg_last_xact is only exported if track_commit_timestamp is enabled.


Metric Collection Configuration​

Metric collection can be controlled via configuration flags:

FlagDescription
CollectBasicBasic server metrics
CollectBackendsBackend/connection details
CollectTablesTable statistics
CollectIndexesIndex statistics
CollectSequencesSequence statistics
CollectFunctionsFunction statistics
CollectSystemSystem metrics
CollectReplicationReplication metrics
CollectQueriesQuery/statement statistics
CollectRolesRole information
CollectTablespacesTablespace metrics
CollectLocksLock metrics
CollectExtensionsExtension information
CollectSettingsConfiguration settings
CollectProgressProgress metrics
CollectPublicationsPublication metrics
CollectSubscriptionsSubscription metrics
CollectMetadataMetadata metrics

PostgreSQL Version Compatibility​

Some metrics are only available in specific PostgreSQL versions:

VersionAdditional Metrics
PG12+checksum_failures, checksum_last_failure, reply_time
PG13+n_ins_since_vacuum, safe_wal_size_bytes, planning time metrics
PG14+pg_wal stats, session time metrics
PG15+apply_error_count, sync_error_count
PG16+last_idx_scan

Was this page helpful?