SQLServerCentral Article

Monitoring Azure SQL Databases


There are many reasons you should monitor your databases, including avoiding performance problems or running out of disk space. Ideally, you want a scalable monitoring solution where you can monitor all your SQL databases in one single place. This article will describe two options that are available: Azure SQL Analytics and Azure SQL Insights. Both are based on Azure Monitor so we will start this article by looking into Azure Monitor.

Note that Azure Monitor is primarily for monitoring Azure SQL databases. For hybrid environments or on-premises SQL Server databases, I would suggest also looking into third-party tools such as Redgate SQL Monitor.

Azure Monitor

Azure Monitor is one of the very core features of Azure. You can find it by just searching for "monitor" in the Azure portal, as you can see in this image:

Azure monitor

Azure Monitor enables you to collect logs and metrics from most Azure Services and use them for purposes such as:

  • Detailed analytics and troubleshooting of your Azure services
  • Alerting and automatic actions based on your collected data (with a bit of code, you can even create automatic actions for auto-scaling your Azure SQL databases)
  • Displaying visualizations on resource overview pages and Azure Dashboards

For example the graph in the Azure portal on the Overview page of an Azure SQL Database is provided by Azure Monitor (see the image below).

Azure SQL Database overview graph

Data collected by Azure Monitor are of two kinds: metrics and logs. Each is described below.


Azure Monitor Metrics are numeric data in a particular structure. They are a lightweight and near real-time collection, so they are useful for alerting and fast detection of issues. You can easily configure metrics-based alerts in Azure Monitor that can notify you about the alert or even take action. You can also view your metrics in interactive visual charts such as the Azure portal overview pages.

Only are a pretty small amount of metrics are available for Azure SQL databases, but they include important data such as resource usage and disk space utilization.


Azure Monitor Logs store data in records with different sets of properties. The logs are like a generic database table with different sets of columns depending of the type of row. You can write queries against the logs using the Kusto query language (KQL) and you can also configure alerts and actions based on the logs.

Logs can contain a wide variety of data. They can provide comprehensive information about Azure SQL databases that can’t be described by only simple metrics. Logs are stored in Log Analytics workspaces. Both Azure SQL Analytics and Azure SQL Insights make use of Azure Monitor logs, so you will need a Log Analytics workspace for your monitoring.

Azure SQL Analytics

Azure SQL Analytics is, as of February 2022, still in preview, although it has been around since at least the beginning of 2018(!). It enables you to monitor all your Azure SQL databases across multiple subscriptions in a single view. It also supports monitoring Managed Instances and Elastic pools.

Below is an example screenshot from Azure SQL Analytics, showing the top  consuming queries and wait types for a database. You can also easily get an overview of query durations, deadlocks, SQLInsights issues and more for all your monitored databases.

Azure SQL Analytics

Azure SQL Analytics doesn't use any agents for collecting data. It relies on metrics and logs collected through Diagnostics settings on your Azure SQL databases.

Azure SQL Analytics can monitor all your Azure SQL databases regardless of private networks and firewalls or different subscriptions. This is because it collects the monitoring data through the diagnostic setting. Unfortunately this prevents the collection from working with on-premises SQL Server databases or databases hosted in VMs.

Azure SQL Analytics setup

To setup Azure SQL Analytics you need to do two things:

  1. Setup data collection from your databases into Log Analytics
  2. Install the Azure SQL Analytics solution

Setup data collection

Make sure you have created a Log Analytics Workspace. If not, just search for Log Analytics workspace in the Azure Portal and create.

On each database you wish to monitor, go to the Diagnostic settings in the left menu in the Azure Portal and create a setting that outputs your desired logs and metrics. Select all logs and metrics. Set the destination to your Log Analytics Workspace.

Azure SQL diagnostic settings

Install the Azure SQL Analytics solution

Search for "azure sql analytics" in the Azure Marketplace. It should then appear under "Marketplace":

Azure SQL Analytics

When you create the solution, select the subscription/resource group where your previously created Log Analytics workspace is located and then select the Log Analytics workspace.

After the creation, you should find Azure SQL Analytics among your resources in the Azure Portal:

Azure SQL analytics solution

To view the monitoring dashboard, open Azure SQL Analytics and click Summary. You should see this tile that says "Azure SQL Analytics", where you can select your Azure Elastic pools, SQL databases, Managed instances or Managed instance databases.

Azure SQL Analytics Solution

Azure SQL Analytics is pretty easy to use. It consists of dashboards where you can click to drill-down into details. For more guidance on how to use Azure SQL Analytics, see the documentation.


Azure SQL Analytics is free, but you will have to pay for your Log Analytics Workspace if you collect more than the free units. See Log Analytics pricing.

Azure SQL Insights

Azure SQL Insights is a monitoring solution that collects data from Dynamic Management Views of the databases. It has been around since March 2021 and is, as of February 2022, still in preview.

Azure SQL Insights can monitor SQL databases from multiple subscriptions and even on-premises SQL Servers, but there are several limitations:

  • It doesn’t work with elastic pools
  • It doesn’t work with lower service tiers (Basic, S0, S1, S2)
  • Currently it only support SQL authentication

Below is a screenshot from the Azure SQL Insights dashboard, showing av overview of resource utilization.

Azure SQL Insights sample

Azure SQL Insights uses an agent, in a separate virtual machine to collect data. This monitoring agent is based on the open-source Telegraf agent and can only run on Azure virtual machines. That makes it a bit difficult to monitor on-premise databases, because your virtual machine then would need network access to those databases. Also if you have separate virtual networks without connectivity, you need to install a separate virtual machine with the agent in each network.

Azure SQL Insights Setup

These are the steps to setup Azure SQL Insights:

  1. Setup a Log Analytics workspace
  2. Create a virtual machine (VM)
  3. Create a monitoring profile
  4. Add your virtual machine to the monitoring profile and configure connection strings

Setup a Log Analytics workspace

Make sure you have created a Log Analytics Workspace. If not, just search for Log Analytics workspace in the Azure Portal and create.

Create a virtual machine

Create a VM for the monitoring agent. As of February 2022, the VM has to run Ubuntu 18.04 as operating system. If you don’t collect data from too many SQL databases, then a size such as  Standard B2s should be sufficient. No special configuration is required, but the VM must have network connectivity to the databases it will monitor.

Create a monitoring profile

Open Azure Monitor and under Insights in the left menu, click SQL.

Azure SQL Insights menu

Choose to create a new monitoring profile. Connect it with your Log Analytics workspace.

Azure SQL Insights create monitoring profile

The default collection settings contain most monitoring options, but you can add more options and change the collection time interval if you wish.

Add your virtual machine to the monitoring profile and configure connection strings

Click Add monitoring machine. Select the VM you created previously.

Add SQL Insights VM

Enter your connection strings in the configuration (remember that only SQL authentication is supported).

Azure SQL Insights configuration


  • You are encouraged to use a key vault for storing your passwords. The sample configuration in the Azure Portal shows you how to configure with a key vault. If you use a key vault, you will need to enable access to the key vault for the managed identity of your VM.
  • Make sure the SQL users specified in the connection strings have enough permissions on the databases being monitored (see under security below).
  • Ensure the VM has connectivity to your databases. If you have databases in multiple virtual networks, you may need to create multiple monitoring machines to be able to connect to all your databases.

Finally click ”Add monitoring virtual machine” to let Azure SQL Insights magically install the monitoring agent on your VM.

Your virtual machine should show status ”Collecting” after a few minutes. If not, click on it to view the log.

Azure SQL insights monitoring status

Now the screen in Azure Monitor under SQL should look like this:

Azure SQL Insights overview

From here you drill-down into your databases, instances and availability groups and get dashboards and tables. You can also click on an icon above any graph to get the KQL query behind it.

Azure SQL Insights KQL query

You can even customize the dashboards with your own graphs by clicking Edit at the top of the screen and then save your own dashboards.

For more guidance on how to use Azure SQL Insights, see the documentation.


It is recommended that you use dedicated SQL users for the purpose of monitoring your databases with a minimal set of privileges. The SQL users need the following permissions in the master database:

GRANT VIEW SERVER STATE TO [your_monitoring_user]
GRANT VIEW ANY DEFINITION TO [your_monitoring_user]

And in each user database:

GRANT VIEW DATABASE STATE TO [your_monitoring_user]

To view the monitoring data in Azure SQL Insights, the user needs at least to belong to the Reader role.


Azure SQL Insights is free, but you will have to pay for the monitoring VMs. Also you will have to pay for your Log Analytics Workspace if you collect more than the free units. See Log Analytics pricing.


This article describes two monitoring options for your Azure SQL databases:

  • Azure SQL Analytics
  • Azure SQL Insights

Both are powerful monitoring options that allow you to monitor your Azure SQL databases in a single view, but they have their pros and cons. Azure SQL Analytics is easier to setup and doesn't require any extra virtual machines. Azure SQL Insights is more customizable, but require you to create virtual machines for the monitoring agent. Adding a virtual machine of course also increases the cost.

These are not the only option though, so for instance, you could use techniques such as Extended events for more advanced monitoring scenarios. For hybrid or on-premises database environments, I would also suggest looking into third-party tools such as Redgate SQL Monitor.



5 (2)

You rated this post out of 5. Change rating




5 (2)

You rated this post out of 5. Change rating