@@ -315,6 +315,16 @@ var builtinMetricMaps = map[string]intermediateMetricMap{
315315 true ,
316316 0 ,
317317 },
318+ "pg_replication_slots" : {
319+ map [string ]ColumnMapping {
320+ "slot_name" : {LABEL , "Name of the replication slot" , nil , nil },
321+ "database" : {LABEL , "Name of the database" , nil , nil },
322+ "active" : {GAUGE , "Flag indicating if the slot is active" , nil , nil },
323+ "pg_wal_lsn_diff" : {GAUGE , "Replication lag in bytes" , nil , nil },
324+ },
325+ true ,
326+ 0 ,
327+ },
318328 "pg_stat_archiver" : {
319329 map [string ]ColumnMapping {
320330 "archived_count" : {COUNTER , "Number of WAL files that have been successfully archived" , nil , nil },
@@ -407,6 +417,16 @@ var queryOverrides = map[string][]OverrideQuery{
407417 },
408418 },
409419
420+ "pg_replication_slots" : {
421+ {
422+ semver .MustParseRange (">=9.4.0" ),
423+ `
424+ SELECT slot_name, database, active, pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)
425+ FROM pg_replication_slots
426+ ` ,
427+ },
428+ },
429+
410430 "pg_stat_archiver" : {
411431 {
412432 semver .MustParseRange (">=0.0.0" ),
0 commit comments