Skip to content

Commit 74d8d5e

Browse files
authored
Merge pull request #2 from kppullin/pg_replication_slots
Add query for 'pg_replication_slots'
2 parents 721430b + a0ced29 commit 74d8d5e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

cmd/postgres_exporter/postgres_exporter.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)