1
0
mirror of https://github.com/prometheus-community/postgres_exporter.git synced 2025-11-25 10:43:13 +03: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:
Jakov Sosic
2020-12-24 16:39:43 +01:00
committed by GitHub
parent bfd0707e37
commit f188bdef53

View File

@@ -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: