Amazon RDS: How to resolve problem that slow query log is stop on the Cloud Watch

Problem

Amazon RDS can output slow query log to Cloud Watch.

f:id:shindo1687:20200411224720p:plain

The cause is unclear but this log is sometimes stop. You can check log is working correctly by SQL below.

select sleep(5);

*The argument value of the sleep function (5 in above example) should same or greater than long_query_time value in the parameter group of Amazon RDS. f:id:shindo1687:20200411225943p:plain

You can see output log on the Cloud Watch when log is working correctly. If you cannot see it, log is stopped.

f:id:shindo1687:20200409215530p:plain

Solution

  1. Edit slow_query_log value of parameter group to 0.
    *The database is not restart by this change because this parameter is dynamic type. f:id:shindo1687:20200411230257p:plain

  2. Wait for database status become Modifying then back to Available.

  3. Edit slow_query_log value of parameter group to 1.

  4. Wait for database status become Modifying then back to Available again.

  5. Execute SQL select sleep(5); then check slow query log is output on the Cloud Watch.