Azure Log Analytics for Azure MySQL database (PaaS Service)

Copper Contributor

Hello Everyone, I need some help in the below issue: I have enabled the diagnostic setting for Azure MySQL database (PaaS Service) in our environment and configured the alert to send the logs to Azure Log Analytics. as per Microsoft SLA for data ingestion to Log Analytics (30 minutes to 6 hours). i tried running the Log analytics query to fetch the MySQL database details but i didn't get any results for that. Query: AzureDiagnostics | where TimeGenerated > ago(7h) | where ResourceProvider == "Microsoft.DBforMySQL" and ResourceType == "Microsoft.DBforMySQL/servers" Note: MySQL database is in East US and Azure Log Analytics is in West US but the query is working for MS SQL database with little modification. I want answer whether the Azure Log Analytics is generally available for MySQL database ? if yes, the can you help me with a sample query to get the output in log analytics. Thanks in Advance !!!!!

4 Replies

@Syed_Aman 

 

Did you get this working?   If not, check this first 

 

 

// check to see which resource providers you have
AzureDiagnostics
| where TimeGenerated > ago(7d)
| summarize by ResourceProvider

If you add a count() to the above, you can see how many records you have by each ResourceProvider

Annotation 2019-05-10 125850.png

 

Then, your query should work (adjust the days/hours to suit)

 

 

AzureDiagnostics
| where TimeGenerated > ago(1d)
| where ResourceProvider == "Microsoft.DBforMySQL" 

 

 

 

 

Thanks@CliveWatson.

 

I am able to get the logs for MySql database in Azure Log Analytics workspace now and i have written a query to get the failed connections details. below is the query

 

AzureDiagnostics
| where SubscriptionId != ""
| where TimeGenerated > ago(10m)
| where ResourceProvider == "MICROSOFT.DBFORMYSQL"
| where Category == "MySqlAuditLogs" and event_class_s == "connection_log"
| where event_subclass_s == "DISCONNECT"
| summarize logoncount= count(), TenantId=arg_max(TenantId, SubscriptionId, ip_s, TimeGenerated, LogicalServerName_s, db_s, ResourceGroup)
| where logoncount > 3
| project TenantId, SubscriptionId, ip_s, logoncount, TimeGenerated, LogicalServerName_s, db_s, ResourceGroup

 

 

but the issue which i am facing in the query is it is just giving me over all DISCONNECT counts and i need help in modifying the filter to get the failed connection count.

Hi @Syed_Aman 

I don't have any DBforMYSQL records 

 

AzureDiagnostics
| where SubscriptionId != ""
| where TimeGenerated > ago(10m)
| where ResourceProvider == "MICROSOFT.DBFORMYSQL"
| where Category == "MySqlAuditLogs" and event_class_s == "connection_log"
| summarize count() by  event_subclass_s 

 

The above should enable you to see what other states, like 'failed' have occurred - sorry I don't have the data so this is a guess!

 

 

This feature is in Private Preview at the moment... see more information here: https://github.com/MicrosoftDocs/azure-docs/issues/26763