Alarm for long running query in mysql

0

Hi We have Aurora Mysql cluster . What is the best way to set alarm for long running queries for example queries that are running more than one hour.

Query
gefragt vor 2 Monaten190 Aufrufe
2 Antworten
2
Akzeptierte Antwort

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

profile picture
EXPERTE
beantwortet vor 2 Monaten
profile picture
EXPERTE
überprüft vor 2 Monaten
profile picture
EXPERTE
überprüft vor 2 Monaten
  • 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 ?

  • for example if I wanted to log queries that has been running for 2 hours what value should I give ?

    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

    How do I use this value to set up the alarm?

    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.

    How do I auto delete/rotate this file ?

    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

0

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 .

Query
beantwortet vor 2 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen