Edit

Enable performance monitoring for Azure SQL Database (preview)

Applies to: Azure SQL Database

This article explains how to enable, verify, and disable performance monitoring for a database in Azure SQL Database, and how to view and query the data that it collects.

Performance monitoring provides a Microsoft-managed monitoring experience for your databases. After you enable monitoring on a database, Azure collects performance data from that database and makes it available for analysis. You don't have to deploy or maintain monitoring agents, data stores, or other monitoring infrastructure.

The collected data provides visibility into resource utilization, database activity, storage performance, active sessions, and wait statistics. Use this data to establish a performance baseline, identify bottlenecks, investigate the cause of performance issues, and find where tuning can improve performance. You can view the data in dashboards, or query it directly with Kusto Query Language (KQL) through an Azure Data Explorer query endpoint.

Note

Performance monitoring for Azure SQL Database is currently in preview. Availability, prerequisites, and supported configurations might change before general availability. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.

How performance monitoring works

You enable performance monitoring for a database by setting the MS_EnablePerformanceMonitoringPreview database-scoped extended property to true in that database. Azure detects the property and starts collecting performance data for the database.

Configure monitoring per database, not per logical server. Setting the property in one database doesn't enable monitoring for other databases on the same logical server.

Supported configurations

During the preview, performance monitoring supports the following Azure SQL Database configurations:

Configuration Supported
Single databases in the DTU-based purchasing model Yes
Single databases in the vCore-based purchasing model, including the General Purpose, Business Critical, and Hyperscale service tiers with 2 or more vCores Yes
Single databases in the serverless compute tier Yes
Databases in an elastic pool No
Secondary replicas, including geo-replicas, named replicas, and read scale-out replicas No

Prerequisites

Before you enable performance monitoring, ensure that you have the following items:

To view or query the collected data, you also need the access prerequisites described later in this article.

Enable performance monitoring collection

Important

Run the script in each user database that you want to monitor. Don't run it in master or another system database. Adding the property to a system database doesn't enable data collection for user databases.

  1. Connect to the user database that you want to monitor. Ensure the database context is the user database, not master.

  2. Run the following script. The script adds the extended property if it doesn't exist, or sets its value to true if it already exists.

    IF EXISTS (
        SELECT 1
        FROM sys.extended_properties
        WHERE class = 0
          AND name = N'MS_EnablePerformanceMonitoringPreview'
    )
    BEGIN
        EXEC sys.sp_updateextendedproperty
            @name = N'MS_EnablePerformanceMonitoringPreview',
            @value = N'true';
    END
    ELSE
    BEGIN
        EXEC sys.sp_addextendedproperty
            @name = N'MS_EnablePerformanceMonitoringPreview',
            @value = N'true';
    END;
    GO
    
  3. Repeat these steps for each database that you want to monitor.

Performance data is usually available to query within 10 minutes after you enable monitoring.

Verify performance monitoring collection

To check whether monitoring is enabled for a database, run the following query in that database:

SELECT name,
       CONVERT(NVARCHAR(128), value) AS value
FROM sys.extended_properties
WHERE class = 0
      AND name = N'MS_EnablePerformanceMonitoringPreview';
GO

The query returns one of the following results:

Result Description
true Monitoring is enabled for the database.
false Monitoring is disabled for the database.
No rows Monitoring isn't set up for the database.

A value of true means that the database is set up for monitoring. To confirm that data is arriving, query the performance data for the database.

Disable performance monitoring collection

To stop collecting new performance data for a database, run the following script in that database. The script keeps the extended property and sets its value to false.

IF EXISTS (
    SELECT 1
    FROM sys.extended_properties
    WHERE class = 0
      AND name = N'MS_EnablePerformanceMonitoringPreview'
)
BEGIN
    EXEC sys.sp_updateextendedproperty
        @name = N'MS_EnablePerformanceMonitoringPreview',
        @value = N'false';
END
ELSE
BEGIN
    EXEC sys.sp_addextendedproperty
        @name = N'MS_EnablePerformanceMonitoringPreview',
        @value = N'false';
END;
GO

To confirm the change, run the verification query again and check that the value is false.

Disabling monitoring stops new data collection. Data that was already collected isn't deleted.

View and query performance data

Enabling performance monitoring starts data collection. To view or query the collected data, you need the access prerequisites in this section. All dashboards and query tools read from the same telemetry endpoint, which enforces Azure role-based access control (Azure RBAC).

Access prerequisites

  • Your account must be a member of the Reader role, or a role with higher privileges, on the subscription that contains the databases you want to query.

  • The Microsoft.Sql resource provider must be registered on each subscription that contains databases you want to query. The resource provider is required only to query the collected data. It isn't required for data collection.

    To register the resource provider, run the following Azure CLI command:

    az provider register --namespace Microsoft.Sql
    

    To check the registration state, run the following command:

    az provider show --namespace Microsoft.Sql --query "registrationState" --output tsv
    

    Registration is complete when the command returns Registered.

View performance data in Fabric Database Hub

Fabric Database Hub provides built-in dashboards that show the performance of your databases in one place. Use the dashboards to review resource utilization, database activity, active sessions, and wait statistics across your database estate, and to drill into an individual database to investigate a performance issue. Fabric Database Hub reads from the same telemetry endpoint described in this article, so the same access prerequisites apply.

You can also create a Real-Time Dashboard in Microsoft Fabric that uses the telemetry endpoint as its data source.

Query performance data with Azure Data Explorer

You can connect directly to the telemetry endpoint and query the performance data by using KQL. Use this option for ad hoc analysis, to build your own queries, or to integrate the data with other tools. For the schema, rules for correct results, and ready-to-run queries, see Query performance monitoring telemetry.

Note

Use the Azure Data Explorer web UI. The Kusto.Explorer desktop client isn't currently supported.

To connect to the telemetry endpoint:

  1. Go to the Azure Data Explorer web UI.

  2. In the Connections pane, select Add, and then select Connection.

  3. For Connection URI, enter https://adx.centralus.arcdataservices.com/kusto/.

    Note

    Use this connection URI for all databases, regardless of the Azure region where the database is located.

  4. Optionally, enter a display name for the connection, and then select Add. If prompted, add the URI as a trusted source.

  5. Expand the connection, and then select the ArcSqlTelemetry database.

  6. Select a table, and then use the query window to write and run KQL queries against your performance data.

Collected datasets

Performance monitoring collects data for Azure SQL Database in the following tables in the ArcSqlTelemetry database. For the columns in each table, see Performance monitoring data schema.

Table Data collected
SqlServerActiveSessions Active sessions
SqlServerCPUUtilization CPU utilization
SqlServerStorageIO Data and log storage I/O
SqlServerDatabaseStorageUtilization Database storage utilization
SqlServerWaitStats Wait statistics
SqlServerDatabaseProperties Database properties
SqlServerMemoryUtilization Memory utilization
SqlServerPerformanceCountersCommon Common performance counters
SqlServerPerformanceCountersDetailed Detailed performance counters

Troubleshoot performance monitoring

The following table describes common issues and how to resolve them.

Issue Cause Resolution
The verification query returns no rows. The extended property wasn't added, or the query ran in a different database. Confirm that you're connected to the user database, and then run the enable script.
The enable script succeeded, but no data appears for the database. The script ran in master instead of the user database, or data is still being processed. Run the verification query in the user database. If the value is true, wait at least 10 minutes, and then query the data again.
The property is set to true, but no data appears for the database. The database is in an elastic pool, or it's a secondary replica. Confirm that the database is in a supported configuration.
The enable script fails with a permission error. Your account doesn't have permission to add a database-level extended property. Connect with an account that's a member of the db_owner role in the user database.
Some databases on a logical server show data and others don't. Monitoring is configured per database. Run the enable script in each database that you want to monitor.
Azure Data Explorer can't connect to the endpoint, or queries return no data for your databases. Your account doesn't have sufficient permissions, or the resource provider isn't registered. Confirm that your account has the Reader role or higher on the subscription, and that Microsoft.AzureArcData is registered.
  • If the verification query returns no rows, the extended property wasn't added or the query ran in a different database. Confirm that you're connected to the user database, and then run the enable script.
  • If the enable script succeeds but no data appears for the database, the script might have run in master instead of the user database, or the data might still be processing. Run the verification query in the user database. If the value is true, wait at least 10 minutes, and then query the data again.
  • If the property is set to true but no data appears for the database, the database might be in an elastic pool or might be a secondary replica. Confirm that the database is in a supported configuration.
  • If the enable script fails with a permission error, your account doesn't have permission to add a database-level extended property. Connect with an account that's a member of the db_owner role in the user database.
  • If some databases on a logical server show data and others don't, monitoring is configured per database. Run the enable script in each database that you want to monitor.
  • If Azure Data Explorer can't connect to the endpoint or queries return no data for your databases, your account might not have sufficient permissions or the resource provider might not be registered. Confirm that your account has the Reader role or higher on the subscription and that Microsoft.AzureArcData is registered.

Platform support

The MS_EnablePerformanceMonitoringPreview database-scoped extended property doesn't enable performance monitoring in SQL Server, Azure SQL Managed Instance, SQL database in Fabric, or Fabric Data Warehouse.