Azure Database for MySQL single server Log queries fail

John Robinson 6 Reputation points
2022-12-15T17:18:59.617+00:00

I'm trying to run a query against the logs for our Mysql db. I navigate to Monitoring | Logs . Then any attempt to run any of the default queries fails with some sort of syntax error.

For example:

// Execution time exceeding a threshold
// Identify queries that their run time exceeds 10 seconds.
// To create an alert for this query, click '+ New alert rule'
AzureDiagnostics
| where ResourceProvider == "MICROSOFT.DBFORMYSQL"
| where Category == 'MySqlSlowLogs'
| project TimeGenerated, LogicalServerName_s, event_class_s, start_time_t , query_time_d, sql_text_s, ResourceId
| where query_time_d > 10 //You may change the time threshold

Fails with this error:

'project' operator: Failed to resolve scalar expression named 'event_class_s'
If the issue persists, please open a support ticket. Request id: 14fa978a-8332-4968-a914-2d9accf13cfe

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,645 questions
Azure Database for MySQL
Azure Database for MySQL
An Azure managed MySQL database service for app development and deployment.
986 questions
{count} votes

1 answer

Sort by: Most helpful
  1. GeethaThatipatri-MSFT 29,542 Reputation points Microsoft Employee Moderator
    2022-12-20T14:23:06.723+00:00

    Hi, @John Robinson The error means, there’s no data in the logs yet. If the logs were enabled just before executing this, it can take a few minutes for the generated logs to arrive in log analytics to be queried.
    It could also mean that, even if log data exists, there are no data in the column ‘event_class_s’. Some of the logs may not have some columns in the data.
    You could customize the KQL query by removing this column from the project or comment the project line to get all columns and then filter to what data you need.

    Examples:
    • Projecting specific columns from the data, removing ‘event_class_s’
    // Execution time exceeding a threshold
    // Identify queries that run time exceeds 10 seconds.
    // To create an alert for this query, click '+ New alert rule'
    AzureDiagnostics
    | where ResourceProvider == "MICROSOFT.DBFORMYSQL"
    | where Category == 'MySqlSlowLogs'
    | project TimeGenerated, LogicalServerName_s, start_time_t , query_time_d, sql_text_s, ResourceId
    | where query_time_d > 10 //You may change the time threshold

    • Projecting all columns

    // Execution time exceeding a threshold
    // Identify queries that run time exceeds 10 seconds.
    // To create an alert for this query, click '+ New alert rule'
    AzureDiagnostics
    | where ResourceProvider == "MICROSOFT.DBFORMYSQL"
    | where Category == 'MySqlSlowLogs'
    //| project TimeGenerated, LogicalServerName_s, event_class_s, start_time_t , query_time_d, sql_text_s, ResourceId
    | where query_time_d > 10 //You may change the time threshold

    I hope this information helps, Please let us know if any further queries.

    Regards
    Geetha

    Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer.


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.