mirror of
https://github.com/prometheus-community/postgres_exporter
synced 2025-04-04 15:19:30 +00:00
Improve PostgreSQL replication lag detection (#395)
In some cases master can show pg_last_xact_replay_timestamp() from past, which can cause the exporter to show ever-growing value for the lag. By checking if the instance is in recovery we can avoid reporting some huge number for master instance.
This commit is contained in:
parent
bfd0707e37
commit
f188bdef53
@ -1,5 +1,5 @@
|
||||
pg_replication:
|
||||
query: "SELECT EXTRACT(EPOCH FROM (now() - pg_last_xact_replay_timestamp())) as lag"
|
||||
query: "SELECT CASE WHEN NOT pg_is_in_recovery() THEN 0 ELSE GREATEST (0, EXTRACT(EPOCH FROM (now() - pg_last_xact_replay_timestamp()))) END AS lag"
|
||||
master: true
|
||||
metrics:
|
||||
- lag:
|
||||
|
Loading…
Reference in New Issue
Block a user