From 99c19cad24b5bb5974403a1e2541fe28ac4c0d53 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Fri, 16 Aug 2024 12:44:12 -0500 Subject: [PATCH] Add compute_receive_lsn metric Useful for dashboarding the replication metrics of a single endpoint. Signed-off-by: Tristan Partin --- vm-image-spec.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vm-image-spec.yaml b/vm-image-spec.yaml index 8c1c4512b4..d1cfbda15d 100644 --- a/vm-image-spec.yaml +++ b/vm-image-spec.yaml @@ -272,6 +272,19 @@ files: else (pg_current_wal_lsn() - '0/0')::FLOAT8 end as lsn; + - metric_name: compute_receive_lsn + type: gauge + help: 'Returns the last write-ahead log location that has been received and synced to disk by streaming replication' + key_labels: + values: [lsn] + query: | + SELECT + CASE + WHEN pg_catalog.pg_is_in_recovery() + THEN (pg_last_wal_receive_lsn() - '0/0')::FLOAT8 + ELSE 0 + END AS lsn; + - metric_name: replication_delay_bytes type: gauge help: 'Bytes between received and replayed LSN'