Monitor Azure SQL Database using Azure SQL Analytics (Preview) in Log Analytics
The Azure SQL Analytics solution in Azure Log Analytics collects and visualizes important SQL Azure performance metrics. By using the metrics that you collect with the solution, you can create custom monitoring rules and alerts. And, you can monitor Azure SQL Database and elastic pool metrics across multiple Azure subscriptions and elastic pools and visualize them. The solution also helps you to identify issues at each layer of your application stack. It uses Azure Diagnostic metrics together with Log Analytics views to present data about all your Azure SQL databases and elastic pools in a single Log Analytics workspace.
Currently, this preview solution supports up to 150,000 Azure SQL Databases and 5,000 SQL Elastic Pools per workspace.
The Azure SQL Analytics solution, like others available for Log Analytics, helps you monitor and receive notifications about the health of your Azure resources—in this case, Azure SQL Database. Microsoft Azure SQL Database is a scalable relational database service that provides familiar SQL-Server-like capabilities to applications running in the Azure cloud. Log Analytics helps you to collect, correlate, and visualize structured and unstructured data.
For a hands-on overview on using Azure SQL Analytics solution and for typical usage scenarios, see the embedded video:
The Azure SQL Analytics solution doesn't use agents to connect to the Log Analytics service.
The following table describes the connected sources that are supported by this solution.
|Windows agents||No||Direct Windows agents are not used by the solution.|
|Linux agents||No||Direct Linux agents are not used by the solution.|
|SCOM management group||No||A direct connection from the SCOM agent to Log Analytics is not used by the solution.|
|Azure storage account||No||Log Analytics does not read the data from a storage account.|
|Azure Diagnostics||Yes||Azure metric and log data are sent to Log Analytics directly by Azure.|
- An Azure Subscription. If you don't have one, you can create one for free.
- A Log Analytics workspace. You can use an existing one, or you can create a new one before you start using this solution.
- Enable Azure Diagnostics for your Azure SQL databases and elastic pools and configure them to send their data to Log Analytics.
Perform the following steps to add the Azure SQL Analytics solution to your workspace.
- Add the Azure SQL Analytics solution to your workspace from Azure marketplace or by using the process described in Add Log Analytics solutions from the Solutions Gallery.
- In the Azure portal, click Create a resource > Monitoring + Management.
- In the Monitoring + Management list click See all.
- In the Recommended list, click More, and then in the new list, find Azure SQL Analytics (Preview) and then select it.
- In the Azure SQL Analytics (Preview) area, click Create.
- In the Create new solution area, select the workspace that you want to add the solution to and then click Create.
To configure multiple Azure subscriptions
To support multiple subscriptions, use the PowerShell script from Enable Azure resource metrics logging using PowerShell. Provide the workspace resource ID as a parameter when executing the script to send diagnostic data from resources in one Azure subscription to a workspace in another Azure subscription.
PS C:\> $WSID = "/subscriptions/<subID>/resourcegroups/oms/providers/microsoft.operationalinsights/workspaces/omsws"
PS C:\> .\Enable-AzureRMDiagnostics.ps1 -WSID $WSID
Using the solution
When you add the solution to your workspace, the Azure SQL Analytics tile is added to your workspace, and it appears in Overview. The tile shows the number of Azure SQL databases and Azure SQL elastic pools that the solution is connected to.
Viewing Azure SQL Analytics data
Click on the Azure SQL Analytics tile to open the Azure SQL Analytics dashboard. The dashboard includes the overview of all databases that are monitored through different perspectives. For different perspectives to work, you must enable proper metrics or logs on your SQL resources to be streamed to Azure Log Analytics workspace.
Selecting any of the tiles, opens a drill-down report into the specific perspective. Once the perspective is selected, the drill-down report is opened.
Each perspective provides summaries on subscription, server, elastic pool, and database level. In addition, each perspective shows a perspective specific to the report on the right. Selecting subscription, server, pool, or database from the list continues the drill-down.
|Resource by type||Perspective that counts all the resources monitored. Drill-down provides the summary of DTU and GB metrics.|
|Insights||Provides hierarchical drill-down into Intelligent Insights. Learn more about intelligent insights.|
|Errors||Provides hierarchical drill-down into SQL errors that happened on the databases.|
|Timeouts||Provides hierarchical drill-down into SQL timeouts that happened on the databases.|
|Blockings||Provides hierarchical drill-down into SQL blockings that happened on the databases.|
|Database waits||Provides hierarchical drill-down into SQL wait statistics on the database level. Includes summaries of total waiting time and the waiting time per wait type.|
|Query duration||Provides hierarchical drill-down into the query execution statistics such as query duration, CPU usage, Data IO usage, Log IO usage.|
|Query waits||Provides hierarchical drill-down into the query wait statistics by wait category.|
Intelligent Insights report
Azure SQL Database Intelligent Insights lets you know what is happening with your database performance. All Intelligent Insights collected can be visualized and accessed through the Insights perspective.
Elastic Pool and Database reports
Both Elastic Pools and Databases have their own specific reports which show all the data that is collected for the resource in the specified time.
Through the Query duration and query waits perspectives, you can correlate the performance of any query through the query report. This report compares the query performance across different databases and makes it easy to pinpoint databases that perform the selected query well versus ones that are slow.
Analyze data and create alerts
You can easily create alerts with the data coming from Azure SQL Database resources. Here are some useful log search queries that you can use for alerting:
High DTU on Azure SQL Database
AzureMetrics | where ResourceProvider=="MICROSOFT.SQL" and ResourceId contains "/DATABASES/" and MetricName=="dtu_consumption_percent" | summarize AggregatedValue = max(Maximum) by bin(TimeGenerated, 5m) | render timechart
High DTU on Azure SQL Database Elastic Pool
AzureMetrics | where ResourceProvider=="MICROSOFT.SQL" and ResourceId contains "/ELASTICPOOLS/" and MetricName=="dtu_consumption_percent" | summarize AggregatedValue = max(Maximum) by bin(TimeGenerated, 5m) | render timechart
You can use these alert-based queries to alert on specific thresholds for both Azure SQL Database and elastic pools. To configure an alert for your Log Analytics workspace:
To configure an alert for your workspace
- Go to the OMS portal and sign in.
- Open the workspace that you have configured for the solution.
- On the Overview page, click the Azure SQL Analytics (Preview) tile.
- Run one of the example queries.
- In Log Search, click Alert.
- On the Add Alert Rule page, configure the appropriate properties and the specific thresholds that you want and then click Save.