56 lines
2.2 KiB
YAML
56 lines
2.2 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:
|
|
0: 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: value
|
|
query:
|
|
0: SELECT max(age(datfrozenxid)) 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
|
|
|
|
# Debugging
|
|
ntables:
|
|
type: value
|
|
query:
|
|
0: SELECT count(*) AS ntables FROM pg_stat_user_tables
|
|
|
|
# Per-replication metrics
|
|
rep_stats:
|
|
type: row
|
|
query:
|
|
0: SELECT * FROM pg_stat_database WHERE client_addr || '_' || regexp_replace(application_name, '[ ,]', '_', 'g') = '{repid}'
|
|
|
|
# Debugging
|
|
sleep:
|
|
type: value
|
|
query:
|
|
0: SELECT now(), pg_sleep(5);
|
|
|
|
# Per-slot metrics
|
|
slot_stats:
|
|
type: row
|
|
query:
|
|
0: 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}'
|