Skip to content

Commit 5116516

Browse files
authored
fix Postgresql replication stat metrics to include replication prefix (#20316)
* fix Postgresql replication stat metrics to include replication prefix * added changelog * fix postgres replication lag metrics * fix postgres replication lag metrics * remove 20316.fixed.1 changelog entry
1 parent 1b01be5 commit 5116516

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

postgres/changelog.d/20316.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fix Postgresql replication stat metrics to include `replication.` prefix

postgres/datadog_checks/postgres/util.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,10 @@ def get_list_chunks(lst, n):
391391
pg_stat_replication.client_addr,
392392
pg_stat_replication_slot.slot_name,
393393
pg_stat_replication_slot.slot_type,
394+
GREATEST (0, age(pg_stat_replication.backend_xmin)) as backend_xmin_age,
394395
GREATEST (0, EXTRACT(epoch from pg_stat_replication.write_lag)) as write_lag,
395-
GREATEST (0, EXTRACT(epoch from pg_stat_replication.replay_lag)) AS replay_lag,
396-
GREATEST (0, age(pg_stat_replication.backend_xmin)) AS backend_xmin_age
396+
GREATEST (0, EXTRACT(epoch from pg_stat_replication.flush_lag)) as flush_lag,
397+
GREATEST (0, EXTRACT(epoch from pg_stat_replication.replay_lag)) AS replay_lag
397398
FROM pg_stat_replication as pg_stat_replication
398399
LEFT JOIN pg_replication_slots as pg_stat_replication_slot
399400
ON pg_stat_replication.pid = pg_stat_replication_slot.active_pid;
@@ -405,9 +406,10 @@ def get_list_chunks(lst, n):
405406
{'name': 'wal_client_addr', 'type': 'tag'},
406407
{'name': 'slot_name', 'type': 'tag_not_null'},
407408
{'name': 'slot_type', 'type': 'tag_not_null'},
408-
{'name': 'wal_write_lag', 'type': 'gauge'},
409-
{'name': 'wal_flush_lag', 'type': 'gauge'},
410-
{'name': 'wal_replay_lag', 'type': 'gauge'},
409+
{'name': 'replication.backend_xmin_age', 'type': 'gauge'},
410+
{'name': 'replication.wal_write_lag', 'type': 'gauge'},
411+
{'name': 'replication.wal_flush_lag', 'type': 'gauge'},
412+
{'name': 'replication.wal_replay_lag', 'type': 'gauge'},
411413
],
412414
}
413415

0 commit comments

Comments
 (0)