Monitoring Azure SQL with Log Analytics
By Tom Nonmacher
In today's data-driven world, monitoring your database server is crucial to ensure optimal performance and quick troubleshooting. For Azure SQL users, Microsoft has provided a powerful tool, Azure Log Analytics, which can be used to monitor, analyze, and optimize your databases. Whether you are using SQL Server 2019, MySQL 8.0, DB2 11.5, Azure SQL, or Azure Synapse, Azure Log Analytics can be an invaluable resource.
Azure Log Analytics is a service in Azure that helps you collect and analyze data generated by resources in your cloud and on-premises environments. It gives you real-time insights using integrated search and custom dashboards to readily analyze millions of records across all your workloads and servers. This post will guide you on how to monitor Azure SQL with Log Analytics.
To begin with, you need to create a Log Analytics Workspace if you do not have one already. The workspace provides a unique environment where Azure Monitor stores data. You can create one from the Azure portal. Once done, you need to enable diagnostics settings for your Azure SQL Database and direct it to send logs to the Log Analytics workspace.
You can use the following T-SQL code snippets to enable diagnostics settings for your Azure SQL Database:
SET SERVERPROPERTY ('EngineEdition') AS EngineEdition,
SET SERVERPROPERTY ('ProductVersion') AS ProductVersion,
SET SERVERPROPERTY ('ProductLevel') AS ProductLevel,
SET SERVERPROPERTY ('Edition') AS Edition,
SET SERVERPROPERTY ('IsClustered') AS IsClustered,
SET SERVERPROPERTY ('HadrManagerStatus') AS HadrManagerStatus
Azure Log Analytics uses a query language known as Kusto Query Language (KQL) for data analysis. With KQL, you can easily retrieve, manipulate, and visualize data. Here's an example of a KQL query that retrieves the top five database names by average CPU percentage:
AzureMetrics
| where ResourceProvider == "MICROSOFT.SQL"
| where MetricName == "cpu_percent"
| summarize avg(CounterValue) by DatabaseName
| top 5 by avg_CounterValue desc
Azure Log Analytics is not just limited to Azure SQL. It can also be used to monitor SQL Server 2019, MySQL 8.0, and DB2 11.5. For instance, to monitor a MySQL 8.0 server, you can install the Log Analytics agent on your MySQL server, and then use KQL queries to analyze the collected data.
In conclusion, Azure Log Analytics provides an effective way to monitor Azure SQL along with other databases like SQL Server 2019, MySQL 8.0, and DB2 11.5. It provides real-time insights using integrated search and custom dashboards, making it easier to analyze and troubleshoot your database server. With the help of KQL, it offers an easy and flexible way to query your data.
Check out the latest articles from all our sites:
- How to Take Advantage of Flash Sales at Grocery Stores [https://www.ethrift.net]
- A brief history of the Galveston Hurricane of 1900 [https://www.galvestonbeachy.com]
- How to Plant and Maintain Chokeberry Bushes [https://www.gardenhomes.org]
- New Query Store Enhancements in SQL Server 2022 [https://www.sqlsupport.org]
- Heat: Why My Laptop Is Cooking My Lap [https://www.SupportMyPC.com]
- The Best Months to Visit South Korea for Cherry Blossoms and Fall Colors [https://www.treasureholidays.com]
Privacy Policy for sqlsupport.org
Last updated: Feb 03, 2026
sqlsupport.org respects your privacy and is committed to protecting any personal information you may provide while using this website.
This Privacy Policy document outlines the types of information that are collected and recorded by sqlsupport.org and how we use it.
Information We Collect
- Internet Protocol (IP) addresses
- Browser type and version
- Pages visited
- Time and date of visits
- Referring URLs
- Device type
Cookies and Web Beacons
sqlsupport.org uses cookies to store information about visitors preferences and to optimize the users experience.
How We Use Your Information
- Operate and maintain our website
- Improve user experience
- Analyze traffic patterns
- Prevent fraudulent activity
Contact
Email: admin@sqlsupport.org