跳至內容

Aurora PG reset aurora_stat_statements statistics daily

0

I want to reset aurora_stat_statements statistics once a day to gather daily snapshots of each of our customers and forward these into Graylog. This would help me understand the most recent problems much better then the otherwise longterm statistics aurora_stat_statements provide.

I have tried SELECT pg_stat_statements_reset(); connected to --dbname=postgres as user that is member of rds_superuser

SHOW shared_preload_libraries; lists "rdsutils,pg_stat_statements,writeforward"

Problem: postgres=> SELECT pg_stat_statements_reset(); ERROR: function pg_stat_statements_reset() does not exist

How can I reset aurora_stat_statements statistics?

已提問 4 個月前檢視次數 114 次
1 個回答
0

To reset the statistics collected by aurora_stat_statements, you should use the standard PostgreSQL function pg_stat_statements_reset(). However, before you can use this function, you need to ensure that the pg_stat_statements extension is properly loaded.

The error message you're seeing indicates that the pg_stat_statements extension might not be loaded in your database. The aurora_stat_statements function builds upon the pg_stat_statements extension and requires it to be enabled.

Here are the steps to resolve this issue:

  1. First, check if the pg_stat_statements extension is included in your shared_preload_libraries parameter in your DB parameter group.

  2. If it's not included, you'll need to add it to the shared_preload_libraries parameter and restart your DB instance.

  3. After ensuring the extension is loaded, you need to create the extension in your database:

CREATE EXTENSION pg_stat_statements;
  1. Once the extension is properly loaded and created, you should be able to use pg_stat_statements_reset() to reset the statistics.

According to the documentation, you can reset stats for the aurora_stat_statements function using pg_stat_statements_reset(). This will reset all the statistics gathered, including the Aurora-specific metrics like storage_blks_read, orcache_blks_hit, and timing information.

For your use case of gathering daily snapshots, you could set up a scheduled task that:

  1. Queries aurora_stat_statements() to capture the current statistics
  2. Forwards this data to Graylog
  3. Calls pg_stat_statements_reset() to reset the statistics for the next day's collection
    Sources
    aurora_stat_statements - Amazon Aurora
    Amazon Aurora PostgreSQL parameters - Amazon Aurora
已回答 4 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。