Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[+] add sent_lag and confirmed_flush_lsn_lag fields to replication metrics #700

Merged
merged 2 commits into from
Dec 28, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions pgwatch2/metrics/replication/10/metric.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ select /* pgwatch2_generated */
(extract(epoch from now()) * 1e9)::int8 as epoch_ns,
application_name as tag_application_name,
concat(coalesce(client_addr::text, client_hostname), '_', client_port::text) as tag_client_info,
coalesce(pg_wal_lsn_diff(case when pg_is_in_recovery() then pg_last_wal_receive_lsn() else pg_current_wal_lsn() end, sent_lsn)::int8, 0) as sent_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, 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,
Expand Down
1 change: 1 addition & 0 deletions pgwatch2/metrics/replication_slots/10/metric_master.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ select /* pgwatch2_generated */
active,
case when active then 0 else 1 end as non_active_int,
pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)::int8 as restart_lsn_lag_b,
pg_wal_lsn_diff(pg_current_wal_lsn(), confirmed_flush_lsn)::int8 as confirmed_flush_lsn_lag_b,
greatest(age(xmin), age(catalog_xmin))::int8 as xmin_age_tx
from
pg_replication_slots;
2 changes: 2 additions & 0 deletions pgwatch2/sql/config_store/metric_definitions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,7 @@ SELECT
(extract(epoch from now()) * 1e9)::int8 as epoch_ns,
application_name as tag_application_name,
concat(coalesce(client_addr::text, client_hostname), '_', client_port::text) as tag_client_info,
coalesce(pg_wal_lsn_diff(case when pg_is_in_recovery() then pg_last_wal_receive_lsn() else pg_current_wal_lsn() end, sent_lsn)::int8, 0) as sent_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, 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,
Expand Down Expand Up @@ -6929,6 +6930,7 @@ select
active,
case when active then 0 else 1 end as non_active_int,
pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)::int8 as restart_lsn_lag_b,
pg_wal_lsn_diff(pg_current_wal_lsn(), confirmed_flush_lsn)::int8 as confirmed_flush_lsn_lag_b,
greatest(age(xmin), age(catalog_xmin))::int8 as xmin_age_tx
from
pg_replication_slots;
Expand Down