Add queries for replication slot monitoring

This commit is contained in:
2025-04-19 02:33:48 -04:00
parent 7fc23961b0
commit 98ac25743b

View File

@@ -8,6 +8,10 @@ metrics:
type: set type: set
query: query:
0: SELECT client_addr || '_' || regexp_replace(application_name, '[ ,]', '_', 'g') AS repid, client_addr, state FROM pg_stat_replication 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 # cluster-wide metrics
version: version:
@@ -43,3 +47,9 @@ metrics:
type: value type: value
query: query:
0: SELECT now(), pg_sleep(5); 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}'