Skip to content

Commit

Permalink
[-] fix timeline ID conversion by cybertec-postgresql/pgwatch2#604
Browse files Browse the repository at this point in the history
  • Loading branch information
pashagolub committed Feb 17, 2023
1 parent 9ce2776 commit 773c822
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/metrics/wal/11/metric.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@ select /* pgwatch3_generated */
end as xlog_location_b,
case when pg_is_in_recovery() then 1 else 0 end as in_recovery_int,
extract(epoch from (now() - pg_postmaster_start_time()))::int8 as postmaster_uptime_s,
system_identifier::text as tag_sys_id
system_identifier::text as tag_sys_id,
case
when pg_is_in_recovery() = false then
('x'||substr(pg_walfile_name(pg_current_wal_lsn()), 1, 8))::bit(32)::int
else
(select min_recovery_end_timeline::int from pg_control_recovery())
end as timeline
from pg_control_system();
8 changes: 7 additions & 1 deletion src/metrics/wal/11/metric_su.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@ select /* pgwatch3_generated */
end as xlog_location_b,
case when pg_is_in_recovery() then 1 else 0 end as in_recovery_int,
extract(epoch from (now() - coalesce((pg_stat_file('postmaster.pid', true)).modification, pg_postmaster_start_time())))::int8 as postmaster_uptime_s,
system_identifier::text as tag_sys_id
system_identifier::text as tag_sys_id,
case
when pg_is_in_recovery() = false then
('x'||substr(pg_walfile_name(pg_current_wal_lsn()), 1, 8))::bit(32)::int
else
(select min_recovery_end_timeline::int from pg_control_recovery())
end as timeline
from pg_control_system();
16 changes: 14 additions & 2 deletions src/sql/config_store/metric_definitions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,13 @@ select
end as xlog_location_b,
case when pg_is_in_recovery() then 1 else 0 end as in_recovery_int,
extract(epoch from (now() - pg_postmaster_start_time()))::int8 as postmaster_uptime_s,
system_identifier::text as tag_sys_id
system_identifier::text as tag_sys_id,
case
when pg_is_in_recovery() = false then
('x'||substr(pg_walfile_name(pg_current_wal_lsn()), 1, 8))::bit(32)::int
else
(select min_recovery_end_timeline::int from pg_control_recovery())
end as timeline
from pg_control_system();
$sql$,
$sql$
Expand All @@ -1102,7 +1108,13 @@ select
end as xlog_location_b,
case when pg_is_in_recovery() then 1 else 0 end as in_recovery_int,
extract(epoch from (now() - coalesce((pg_stat_file('postmaster.pid', true)).modification, pg_postmaster_start_time())))::int8 as postmaster_uptime_s,
system_identifier::text as tag_sys_id
system_identifier::text as tag_sys_id,
case
when pg_is_in_recovery() = false then
('x'||substr(pg_walfile_name(pg_current_wal_lsn()), 1, 8))::bit(32)::int
else
(select min_recovery_end_timeline::int from pg_control_recovery())
end as timeline
from pg_control_system();
$sql$,
'{"prometheus_gauge_columns": ["in_recovery_int", "postmaster_uptime_s"]}'
Expand Down

0 comments on commit 773c822

Please sign in to comment.