- Newest
- Most votes
- Most comments
Hello.
If I were to output slow query logs, I would set up a metrics filter so that they are registered in metrics at the same time they are output.
Create an alarm for that metric.
https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_LogAccess.MySQL.LogFileSize.html
Alternatively, you can set a subscription filter on the slow query log log group and have it notified via Lambda.
Unlike metric filters, subscription filters allow you to easily create a configuration that notifies you of log messages as they are.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/SubscriptionFilters.html#LambdaFunctionExample
But from my understanding this would only help queries that already executed. I’m looking for queries that are running or currently executing for certain period of time .
Relevant content
- asked 4 years ago
- asked 2 years ago
- asked 3 years ago
- asked 2 years ago
- AWS OFFICIALUpdated 2 years ago
- How do I end long-running queries in my Amazon RDS for PostrgreSQL or Aurora PostgreSQL DB instance?AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated a year ago
Thank you for your response , I'm bit confused about setting slow query time. for example if I wanted to log queries that has been running for 2 hours what value should I give ? How do I use this value to set up the alarm? How do I auto delete/rotate this file ?
If you set "long_query_time" in the parameter group to "7,200", only queries that took more than 2 hours will be output to the log. https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_LogAccess.MySQL.LogFileSize.html#USER_LogAccess.MySQL.Generallog
In the case of metrics filters, slow queries occur when metrics are registered, so I think you should set the alarm threshold to 1 or higher.
I think you should set the retention period for the CloudWatch Logs log group. https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html
Thank you.
In the case of metrics filters, slow queries occur when metrics are registered, so I think you should set the alarm threshold to 1 or higher.
As I went thru cloudwatch, I’m not sure how would I create metrics pattern for slow queries? Do you have any example How do I set this metric pattern to set the alarm
If you want to register all queries output to the slow query log in metrics, I think you can register them all by leaving the filter pattern empty. https://aws.amazon.com/jp/blogs/database/monitor-amazon-rds-for-mysql-and-mariadb-logs-with-amazon-cloudwatch/
So What am looking here is to find long running queries that currently being executing/running more than certain amount of time . Which is something I need to get alerts. Slow queries output we get after queries being executed. Hope you can help