跳至内容

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 个月前111 查看次数
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 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。