Sitelet https://github.com/cybertec-postgresql/pgwatch/pull/930
Skip to content

[!] remove obsolete db_stats_aurora metric - #930

Merged
pashagolub merged 3 commits into
masterfrom
deprecate_db_stats_aurora
Sep 2, 2025
Merged

pashagolub merged 3 commits into
masterfrom
deprecate_db_stats_aurora

Conversation

@pashagolub

Copy link
Copy Markdown
Collaborator

The db_stats_aurora metric was created as a workaround for early AWS Aurora PostgreSQL limitations that prevented using certain PostgreSQL functions like pg_backup_start_time() and complex subqueries for invalid index detection.

Modern Aurora PostgreSQL versions (13+) now support virtually all standard PostgreSQL administration functions, making this Aurora-specific variant unnecessary. Users can simply use the standard db_stats metric instead, which provides the same functionality plus additional features like backup duration tracking and invalid index monitoring.

This removal reduces maintenance overhead and eliminates confusing

The `db_stats_aurora` metric was created as a workaround for early
AWS Aurora PostgreSQL limitations that prevented using certain
PostgreSQL functions like pg_backup_start_time() and complex subqueries
for invalid index detection.

Modern Aurora PostgreSQL versions (13+) now support virtually all
standard PostgreSQL administration functions, making this
Aurora-specific variant unnecessary. Users can simply use the standard
`db_stats` metric instead, which provides the same functionality
plus additional features like backup duration tracking and invalid
index monitoring.

This removal reduces maintenance overhead and eliminates confusing
@pashagolub pashagolub changed the title [!] deprecate db_stats_aurora metric [!] remove obsolete db_stats_aurora metric Sep 2, 2025
@pashagolub pashagolub self-assigned this Sep 2, 2025
@pashagolub pashagolub added the metrics Metrics related issues label Sep 2, 2025
@coveralls

coveralls commented Sep 2, 2025 •

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 17397399850

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 64.114%

Totals Coverage Status
Change from base Build 17397070760: 0.0%
Covered Lines: 3198
Relevant Lines: 4988

馃挍 - Coveralls

@pashagolub
pashagolub merged commit 6b24faa into master Sep 2, 2025
6 checks passed
@pashagolub
pashagolub deleted the deprecate_db_stats_aurora branch September 2, 2025 08:13
@f9n

f9n commented Mar 8, 2026 •

Copy link
Copy Markdown
Contributor

Hi @pashagolub ,

Thanks for the cleanup! However, I'm running into an issue after the removal of the aurora preset.

Since the preset was removed, I started using the rds preset for my AWS Aurora instances, but I'm now getting the following error regarding the wal metric:

[ERROR] [metric:wal] [count:1] [error:ERROR: Function pg_last_xlog_replay_location() is currently not supported for Aurora (SQLSTATE 0A000)] failed to fetch metric data

It seems that while Aurora 13+ supports most standard admin functions, standard WAL functions are still not supported due to its custom storage engine.

I did some digging to see if we could bypass this in the SQL using a CASE statement. Would you consider updating the standard wal metric query to something like this to gracefully handle Aurora instances without needing a separate preset?

        wal:
            description: >
                This metric collects information about the Write-Ahead Logging (WAL) system in PostgreSQL.
                It provides insights into WAL activity, including the current WAL location, replay lag, and other related metrics.
            sqls:
                11: |-
                    select /* pgwatch_generated */
                    (extract(epoch from now()) * 1e9)::int8 as epoch_ns,
                    case
                        when exists (select 1 from pg_settings where name like 'aurora%') then null
                        when pg_is_in_recovery() = false then
                        pg_wal_lsn_diff(pg_current_wal_lsn(), '0/0')::int8
                        else
                        pg_wal_lsn_diff(pg_last_wal_replay_lsn(), '0/0')::int8
                        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,
                    case
                        when exists (select 1 from pg_settings where name like 'aurora%') then null
                        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()
            gauges:
                - '*'
            is_instance_level: true
        wal_receiver:
            description: >
                This metric collects information about the WAL receiver process in PostgreSQL.
                It provides insights into the status of the WAL receiver, including replay lag and last replay timestamp.
            sqls:
                11: |-
                    select /* pgwatch_generated */
                      (extract(epoch from now()) * 1e9)::int8 as epoch_ns,
                      case
                        when exists (select 1 from pg_settings where name like 'aurora%') then null
                        else pg_wal_lsn_diff(pg_last_wal_receive_lsn(), pg_last_wal_replay_lsn())::int8
                      end as replay_lag_b,
                      case
                        when exists (select 1 from pg_settings where name like 'aurora%') then null
                        else extract(epoch from (now() - pg_last_xact_replay_timestamp()))::int8
                      end as last_replay_s
            node_status: standby
            gauges:
                - '*'
            is_instance_level: true

@0xgouda

0xgouda commented Mar 16, 2026

Copy link
Copy Markdown
Collaborator

@f9n

I guess it's better to leave the metrics as they are, so it's clearer to new users that the wal and wal_reciever metrics are not compatible with Aurora, instead of just silently consuming storage while showing nothing useful on the dashboards.

But I will revert this and recreate an aurora preset that doesn't include wal and wal_receiver, does that work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

metrics Metrics related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants