How to log _all_queries run in a mysql instance

John Robinson 6 Reputation points
2022-12-23T11:45:35.227+00:00

We have a Mysql single server and would like to log all of the queries that are run on it (not just the 'slow' ones). What settings do we need to configure to achieve this?

We have currently configured the Azure Diagnostic Settings so that the MySql Audit Logs are archived to a storage account. I can see that data is being written to that account in the following structure:

insights-metrics-pt1m/resourceId=/SUBSCRIPTIONS/

Azure Database for MySQL
Azure Database for MySQL
An Azure managed MySQL database service for app development and deployment.
986 questions
{count} votes

2 answers

Sort by: Most helpful
  1. John Robinson 6 Reputation points
    2023-01-27T10:04:23.5533333+00:00

    Hi Shakti,

    This is working now. I selected all logs and configured them to be sent to an analytics workspace. However, I then needed to set the following server parameters:

    audit_log_enabled: ON
    audit
    
    1 person found this answer helpful.

  2. John Robinson 6 Reputation points
    2023-01-27T10:10:48.4966667+00:00

    Hi Shakti,

    This works now. I configured the Diagnostic Setting as in your screenshot and set the following server parameters:

    audit
    audit_log_events: DML
    

    This logged all of the queries to the insights-logs-mysqlauditlogs blob container under the storage account configured in the diagnostic settings.

    I then noticed that I only needed to send the 'MySQL Audit Logs' to the container not 'AllLogs' so updated the Diagnostic Setting. It all still works nicely.

    Thankyou for all your help. It is very much appreciated.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.