Monitoring an Azure SQL Database and SQL Managed Instance using DMVs
DMVs return diagnostic data that can be used to monitor a database's health and performance. We'll cover monitoring data metrics, connection statistics, blocking status, and query performance in the following sections.
Monitoring database metrics
The Azure SQL Database metrics available on the Azure portal can also be monitored using the sys.resource_stats
DMV. This DMV returns the historical analysis for all the databases in an Azure SQL server. For SQL Managed Instance, you can use the sys.server_resource_stats
DMV to monitor SQL Managed Instance CPU storage usage. The data for this DMV is collected and aggregated every 5 minutes and is retained for 14 days.
The following query returns the resource utilization from the last six hours for the Azure SQL Database:
-- Execute in master database -- Get utilization in last 6 hours for the toystore database Declare @StartTime DATETIME = DATEADD...