2024-10-24 16:23:19 +00:00
metrics :
# Discovery metrics
discover_dbs :
type : set
query :
2024-10-29 06:51:57 +00:00
0 : SELECT datname AS dbname FROM pg_database
2024-10-24 16:23:19 +00:00
discover_rep :
type : set
query :
0 : SELECT client_addr || '_' || regexp_replace(application_name, '[ ,]', '_', 'g') AS repid, client_addr, state FROM pg_stat_replication
2025-04-19 06:33:48 +00:00
discover_slots :
type : set
query :
2025-06-01 04:11:44 +00:00
90400 : SELECT slot_name, plugin, slot_type, database, false as temporary, active FROM pg_replication_slots
2025-05-22 18:53:25 +00:00
100000 : SELECT slot_name, plugin, slot_type, database, temporary, active FROM pg_replication_slots
2024-10-24 16:23:19 +00:00
# cluster-wide metrics
version :
type : value
query :
0 : SHOW server_version_num
max_frozen_age :
2025-06-01 04:11:44 +00:00
type : row
2024-10-24 16:23:19 +00:00
query :
2025-06-04 04:47:51 +00:00
0 : SELECT max(age(datfrozenxid)) AS xid_age, max(mxid_age(datminmxid)) AS mxid_age FROM pg_database
2024-10-24 16:23:19 +00:00
# Per-database metrics
db_stats :
type : row
query :
2024-10-29 06:51:57 +00:00
0 : SELECT numbackends, xact_commit, xact_rollback, blks_read, blks_hit, tup_returned, tup_fetched, tup_inserted, tup_updated, tup_deleted, conflicts, temp_files, temp_bytes, deadlocks, blk_read_time, blk_write_time, extract('epoch' from stats_reset)::float FROM pg_stat_database WHERE datname = %(dbname)s
140000 : SELECT numbackends, xact_commit, xact_rollback, blks_read, blks_hit, tup_returned, tup_fetched, tup_inserted, tup_updated, tup_deleted, conflicts, temp_files, temp_bytes, deadlocks, COALESCE(checksum_failures, 0) AS checksum_failures, blk_read_time, blk_write_time, session_time, active_time, idle_in_transaction_time, sessions, sessions_abandoned, sessions_fatal, sessions_killed, extract('epoch' from stats_reset)::float FROM pg_stat_database WHERE datname = %(dbname)s
2025-05-22 18:53:25 +00:00
test_args :
dbname : postgres
2024-10-29 06:51:57 +00:00
# Debugging
ntables :
type : value
query :
2025-01-08 22:12:35 +00:00
0 : SELECT count(*) AS ntables FROM pg_stat_user_tables
2024-10-24 16:23:19 +00:00
# Per-replication metrics
rep_stats :
type : row
query :
2025-06-01 04:11:44 +00:00
90400 : SELECT * FROM pg_stat_replication WHERE client_addr || '_' || regexp_replace(application_name, '[ ,]', '_', 'g') = '{repid}'
2025-05-22 18:53:25 +00:00
test_args :
repid : 127.0 .0 .1_test_rep
2024-10-24 16:23:19 +00:00
2025-04-19 06:33:48 +00:00
# Per-slot metrics
slot_stats :
type : row
query :
2025-06-01 04:11:44 +00:00
90400 : SELECT active_pid, xmin, pg_xlog_location_diff(pg_current_xlog_location(), restart_lsn) AS restart_bytes, pg_xlog_location_diff(pg_current_xlog_location(), confirmed_flush_lsn) AS confirmed_flush_bytes FROM pg_replication_slots WHERE slot_name = '{slot}'
2025-05-22 18:53:25 +00:00
100000 : SELECT active_pid, xmin, pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn) AS restart_bytes, pg_wal_lsn_diff(pg_current_wal_lsn(), confirmed_flush_lsn) AS confirmed_flush_bytes FROM pg_replication_slots WHERE slot_name = '{slot}'
test_args :
slot : test_slot