Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

[+] add lag in milliseconds to replication metrics #607

Merged
merged 1 commit into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pgwatch2/metrics/replication/10/metric.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ select /* pgwatch2_generated */
coalesce(pg_wal_lsn_diff(case when pg_is_in_recovery() then pg_last_wal_receive_lsn() else pg_current_wal_lsn() end, write_lsn)::int8, 0) as write_lag_b,
coalesce(pg_wal_lsn_diff(case when pg_is_in_recovery() then pg_last_wal_receive_lsn() else pg_current_wal_lsn() end, flush_lsn)::int8, 0) as flush_lag_b,
coalesce(pg_wal_lsn_diff(case when pg_is_in_recovery() then pg_last_wal_receive_lsn() else pg_current_wal_lsn() end, replay_lsn)::int8, 0) as replay_lag_b,
(extract(epoch from write_lag) * 1000)::int8 as write_lag_ms,
(extract(epoch from flush_lag) * 1000)::int8 as flush_lag_ms,
(extract(epoch from replay_lag) * 1000)::int8 as replay_lag_ms,
state,
sync_state,
case when sync_state in ('sync', 'quorum') then 1 else 0 end as is_sync_int,
Expand Down
3 changes: 3 additions & 0 deletions pgwatch2/sql/config_store/metric_definitions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,9 @@ SELECT
coalesce(pg_wal_lsn_diff(case when pg_is_in_recovery() then pg_last_wal_receive_lsn() else pg_current_wal_lsn() end, write_lsn)::int8, 0) as write_lag_b,
coalesce(pg_wal_lsn_diff(case when pg_is_in_recovery() then pg_last_wal_receive_lsn() else pg_current_wal_lsn() end, flush_lsn)::int8, 0) as flush_lag_b,
coalesce(pg_wal_lsn_diff(case when pg_is_in_recovery() then pg_last_wal_receive_lsn() else pg_current_wal_lsn() end, replay_lsn)::int8, 0) as replay_lag_b,
(extract(epoch from write_lag) * 1000)::int8 as write_lag_ms,
(extract(epoch from flush_lag) * 1000)::int8 as flush_lag_ms,
(extract(epoch from replay_lag) * 1000)::int8 as replay_lag_ms,
state,
sync_state,
case when sync_state in ('sync', 'quorum') then 1 else 0 end as is_sync_int,
Expand Down