APPLIES TO: Azure SQL Database, Azure SQL Managed Instance
Azure SQL Analytics (preview) is an advanced cloud monitoring solution for monitoring performance of all of your Azure SQL databases at scale and across multiple subscriptions in a single view. Azure SQL Analytics collects and visualizes key performance metrics with built-in intelligence for performance troubleshooting.
By using these collected metrics, you can create custom monitoring rules and alerts. Azure SQL Analytics helps you to identify issues at each layer of your application stack. Azure SQL Analytics uses Azure Diagnostics metrics along with Azure Monitor views to present data about all your Azure SQL databases in a single Log Analytics workspace. Azure Monitor helps you to collect, correlate, and visualize structured and unstructured data.
Connected sourcesAzure SQL Analytics is a cloud-only monitoring solution supporting streaming of diagnostics telemetry for all of your Azure SQL databases. Because Azure SQL Analytics does not use agents to connect to Azure Monitor, it does not support monitoring of SQL Server hosted on-premises or in virtual machines.
Azure SQL Analytics optionsThe below table outlines supported options for two versions of the Azure SQL Analytics dashboard, one for Azure SQL Database, and the other one for Azure SQL Managed Instance databases.
Azure SQL Analytics option Description SQL Database support SQL Managed Instance support Resource by type Perspective that counts all the resources monitored. Yes Yes Insights Provides hierarchical drill-down into Intelligent Insights into performance. Yes Yes Errors Provides hierarchical drill-down into SQL errors that happened on the databases. Yes Yes Timeouts Provides hierarchical drill-down into SQL timeouts that happened on the databases. Yes No Blockings Provides hierarchical drill-down into SQL blockings that happened on the databases. Yes No 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. Yes No Query duration Provides hierarchical drill-down into the query execution statistics such as query duration, CPU usage, Data IO usage, Log IO usage. Yes Yes Query waits Provides hierarchical drill-down into the query wait statistics by wait category. Yes Yes Configuration of Azure SQL Analytics (preview)Use the process described in Add Azure Monitor solutions from the Solutions Gallery to add Azure SQL Analytics (Preview) to your Log Analytics workspace.
Configure Azure SQL Database to stream diagnostics telemetryOnce you have created Azure SQL Analytics solution in your workspace, you need to configure each resource that you want to monitor to stream its diagnostics telemetry to Azure SQL Analytics. Follow detailed instructions on this page:
The above page also provides instructions on enabling support for monitoring multiple Azure subscriptions from a single Azure SQL Analytics workspace as a single pane of glass.
Use Azure SQL Analytics (preview)Navigate to your SQL Analytics deployment from the Legacy solutions page of the Log Analytics workspace.
Azure SQL Analytics provides two separate views: one for monitoring SQL Database, and the other view for monitoring SQL Managed Instance.
Viewing Azure SQL Analytics dataThe 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 Log Analytics workspace.
If some metrics or logs are not streamed into Azure Monitor, the tiles in Azure SQL Analytics are not populated with monitoring information.
SQL Database viewOnce the Azure SQL Analytics tile for the database is selected, the monitoring dashboard is shown.
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 in this view provides summaries at the subscription, server, elastic pool, and database levels. 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.
SQL Managed Instance viewOnce the Azure SQL Analytics tile for the databases is selected, the monitoring dashboard is shown.
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.
Selecting the SQL Managed Instance view, shows details on the instance utilization, instance databases, and telemetry on the queries executed across the managed instance.
Intelligent Insights reportAzure SQL Database Intelligent Insights lets you know what is happening with performance of all Azure SQL databases. All Intelligent Insights collected can be visualized and accessed through the Insights perspective.
Elastic pools and database reportsBoth elastic pools and databases have their own specific reports that show all the data that is collected for the resource in the specified time.
Query reportsThrough 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.
PermissionsTo use Azure SQL Analytics (preview), users need to be granted a minimum permission of the Reader role in Azure. This role, however, does not allow users to see the query text, or perform any Automatic tuning actions. More permissive roles in Azure that allow using Azure SQL Analytics to the fullest extent are Owner, Contributor, SQL DB Contributor, or SQL Server Contributor. You also might want to consider creating a custom role in the portal with specific permissions required only to use Azure SQL Analytics, and with no access to managing other resources.
Create a custom role in portalRecognizing that some organizations enforce strict permission controls in Azure, find the following PowerShell script enabling creation of a custom role "SQL Analytics Monitoring Operator" in Azure portal with the minimum read and write permissions required to use Azure SQL Analytics to its fullest extent.
Replace the "{SubscriptionId}" in the below script with your Azure subscription ID, and execute the script logged in as an Owner or Contributor role in Azure.
Connect-AzAccount
Select-AzSubscription {SubscriptionId}
$role = Get-AzRoleDefinition -Name Reader
$role.Name = "SQL Analytics Monitoring Operator"
$role.Description = "Lets you monitor database performance with Azure SQL Analytics as a reader. Does not allow change of resources."
$role.IsCustom = $true
$role.Actions.Add("Microsoft.SQL/servers/databases/read");
$role.Actions.Add("Microsoft.SQL/servers/databases/topQueries/queryText/*");
$role.Actions.Add("Microsoft.Sql/servers/databases/advisors/read");
$role.Actions.Add("Microsoft.Sql/servers/databases/advisors/write");
$role.Actions.Add("Microsoft.Sql/servers/databases/advisors/recommendedActions/read");
$role.Actions.Add("Microsoft.Sql/servers/databases/advisors/recommendedActions/write");
$role.Actions.Add("Microsoft.Sql/servers/databases/automaticTuning/read");
$role.Actions.Add("Microsoft.Sql/servers/databases/automaticTuning/write");
$role.Actions.Add("Microsoft.Sql/servers/advisors/read");
$role.Actions.Add("Microsoft.Sql/servers/advisors/write");
$role.Actions.Add("Microsoft.Sql/servers/advisors/recommendedActions/read");
$role.Actions.Add("Microsoft.Sql/servers/advisors/recommendedActions/write");
$role.Actions.Add("Microsoft.Resources/deployments/write");
$role.AssignableScopes = "/subscriptions/{SubscriptionId}"
New-AzRoleDefinition $role
Once the new role is created, assign this role to each user that you need to grant custom permissions to use Azure SQL Analytics.
Analyze data and create alertsData analysis in Azure SQL Analytics is based on Log Analytics language for your custom querying and reporting. Find description of the available data collected from database resource for custom querying in metrics and logs available.
Automated alerting in Azure SQL Analytics is based on writing a Log Analytics query that triggers an alert upon a condition met. Find below several examples on Log Analytics queries upon which alerting can be set up in Azure SQL Analytics.
Create alerts for Azure SQL DatabaseYou can easily create alerts with the data coming from Azure SQL Database resources. Here are some useful log queries that you can use with a log alert:
High CPUAzureMetrics
| where ResourceProvider=="MICROSOFT.SQL"
| where ResourceId contains "/DATABASES/"
| where MetricName=="cpu_percent"
| summarize AggregatedValue = max(Maximum) by bin(TimeGenerated, 5m)
| render timechart
Note
cpu_percent
with dtu_consumption_percent
to obtain high DTU results instead.AzureMetrics
| where ResourceProvider=="MICROSOFT.SQL"
| where ResourceId contains "/ELASTICPOOLS/"
| where MetricName=="cpu_percent"
| summarize AggregatedValue = max(Maximum) by bin(TimeGenerated, 5m)
| render timechart
Note
cpu_percent
with dtu_consumption_percent
to obtain high DTU results instead.let time_range = 1h;
let storage_threshold = 95;
AzureMetrics
| where ResourceId contains "/DATABASES/"
| where MetricName == "storage_percent"
| summarize max_storage = max(Average) by ResourceId, bin(TimeGenerated, time_range)
| where max_storage > storage_threshold
| distinct ResourceId
Note
storage_threshold
within the time_range
defined.storage_threshold
within the time_range
defined.Important
In case a database is performing well, and that no Intelligent Insights have been generated, this query will fail with an error message: Failed to resolve scalar expression named rootCauseAnalysis_s
. This behavior is expected for all cases where there exist no intelligent insights for the database.
let alert_run_interval = 1h;
let insights_string = "hitting its CPU limits";
AzureDiagnostics
| where Category == "SQLInsights" and status_s == "Active"
| where TimeGenerated > ago(alert_run_interval)
| where rootCauseAnalysis_s contains insights_string
| distinct ResourceId
Note
alert_run_interval
in order to avoid duplicate results. The rule should be set up to fire off the alert when there exist results (> 0 results) from the query.alert_run_interval
to specify the time range to check if the condition has occurred on databases configured to stream SQLInsights log to Azure SQL Analytics.AzureDiagnostics
| where Category == "SQLInsights" and status_s == "Active"
| distinct rootCauseAnalysis_s
Create alerts for SQL Managed Instance Storage is above 90%
let storage_percentage_threshold = 90;
AzureDiagnostics
| where Category =="ResourceUsageStats"
| summarize (TimeGenerated, calculated_storage_percentage) = arg_max(TimeGenerated, todouble(storage_space_used_mb_s) *100 / todouble (reserved_storage_mb_s))
by ResourceId
| where calculated_storage_percentage > storage_percentage_threshold
Note
let cpu_percentage_threshold = 95;
let time_threshold = ago(1h);
AzureDiagnostics
| where Category == "ResourceUsageStats" and TimeGenerated > time_threshold
| summarize avg_cpu = max(todouble(avg_cpu_percent_s)) by ResourceId
| where avg_cpu > cpu_percentage_threshold
Note
While Azure SQL Analytics (preview) is free to use, consumption of diagnostics telemetry above the free units of data ingestion allocated each month applies, see Log Analytics pricing. The free units of data ingestion provided enable free monitoring of several databases each month. More active databases with heavier workloads ingest more data versus idle databases. You can easily monitor your data ingestion consumption in Azure SQL Analytics by selecting OMS Workspace on the navigation menu of Azure SQL Analytics, and then selecting Usage and Estimated Costs.
Next stepsRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4