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

Skip collecting wal if db is aurora #55

Closed
wants to merge 1 commit into from

Conversation

caflamand
Copy link

Hello!

I'm was trying to run pgmetrics from linux to get metrics for our AWS RDS Aurora Cluster (14.4), but I was getting the following fatal error when trying to do so.

pgmetrics: pg_stat_wal query failed: pq: Function pg_stat_get_wal() is currently not supported for Aurora

Aurora not supporting wal metrics seems to be a known issue for pgmetrics, see below:

func (c *collector) getWalReceiverv96() {
// skip if Aurora, because the function errors out with:
// "Function pg_stat_get_wal_receiver() is currently not supported in Aurora"
if c.isAWSAurora() {
return
}

After some investigation, I found that the error was being raised by the getWal() function, which is missing the c.isAWSAurora() check.

pgmetrics/collector/collect.go

Lines 2417 to 2436 in 35516b5

func (c *collector) getWAL() {
ctx, cancel := context.WithTimeout(context.Background(), c.timeout)
defer cancel()
// pg_stat_wal has only 1 row
q := `SELECT wal_records, wal_fpi, wal_bytes, wal_buffers_full, wal_write,
wal_sync, wal_write_time, wal_sync_time,
COALESCE(EXTRACT(EPOCH FROM stats_reset)::bigint, 0)
FROM pg_stat_wal
LIMIT 1`
var w pgmetrics.WAL
err := c.db.QueryRowContext(ctx, q).Scan(&w.Records, &w.FPI, &w.Bytes,
&w.BuffersFull, &w.Write, &w.Sync, &w.WriteTime, &w.SyncTime,
&w.StatsReset)
if err != nil {
log.Fatalf("pg_stat_wal query failed: %v", err)
}
c.result.WAL = &w
}

I recompiled locally with the check and it fixed my issue.

The call to the getWal() function has been introduced more than a year ago. I couldn't find any related issues in the repo, am I the first one to have this issue?

@mdevan
Copy link
Contributor

mdevan commented Oct 28, 2022

Thanks for the report and fix. We'll merge/provide a fix in the upcoming release (likely next week).

mdevan added a commit that referenced this pull request Nov 3, 2022
@mdevan
Copy link
Contributor

mdevan commented Nov 7, 2022

Available in release v1.14.0.

(Note: Also use latest pgdash CLI v1.10.0 to send to pgDash server.)

@mdevan mdevan closed this Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants