58 lines
2.6 KiB
YAML
58 lines
2.6 KiB
YAML
metrics:
|
|
# Discovery metrics
|
|
discover_dbs:
|
|
type: set
|
|
query:
|
|
0: SELECT datname AS dbname FROM pg_database
|
|
discover_rep:
|
|
type: set
|
|
query:
|
|
0: SELECT client_addr || '_' || regexp_replace(application_name, '[ ,]', '_', 'g') AS repid, client_addr, state FROM pg_stat_replication
|
|
discover_slots:
|
|
type: set
|
|
query:
|
|
90400: SELECT slot_name, plugin, slot_type, database, false as temporary, active FROM pg_replication_slots
|
|
100000: SELECT slot_name, plugin, slot_type, database, temporary, active FROM pg_replication_slots
|
|
|
|
# cluster-wide metrics
|
|
version:
|
|
type: value
|
|
query:
|
|
0: SHOW server_version_num
|
|
max_frozen_age:
|
|
type: row
|
|
query:
|
|
0: SELECT max(age(datfrozenxid)) AS xid_age, max(mxid_age(datminmxid)) AS mxid_age FROM pg_database
|
|
|
|
# Per-database metrics
|
|
db_stats:
|
|
type: row
|
|
query:
|
|
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
|
|
test_args:
|
|
dbname: postgres
|
|
|
|
# Debugging
|
|
ntables:
|
|
type: value
|
|
query:
|
|
0: SELECT count(*) AS ntables FROM pg_stat_user_tables
|
|
|
|
# Per-replication metrics
|
|
rep_stats:
|
|
type: row
|
|
query:
|
|
90400: SELECT * FROM pg_stat_replication WHERE client_addr || '_' || regexp_replace(application_name, '[ ,]', '_', 'g') = '{repid}'
|
|
test_args:
|
|
repid: 127.0.0.1_test_rep
|
|
|
|
# Per-slot metrics
|
|
slot_stats:
|
|
type: row
|
|
query:
|
|
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}'
|
|
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
|