내용으로 건너뛰기

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달 전116회 조회
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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠