|
| 1 | +--- |
| 2 | +title: "sys.server_resource_stats (Azure SQL Database) | Microsoft Docs" |
| 3 | +ms.custom: "" |
| 4 | +ms.date: "06/28/2018" |
| 5 | +ms.prod: "" |
| 6 | +ms.prod_service: "sql-database" |
| 7 | +ms.component: |
| 8 | +ms.reviewer: carlrab, edmaca |
| 9 | +ms.suite: "sql" |
| 10 | +ms.technology: |
| 11 | +ms.tgt_pltfrm: "" |
| 12 | +ms.topic: "language-reference" |
| 13 | +f1_keywords: |
| 14 | + - "resource_stats" |
| 15 | + - "sys.resource_stats" |
| 16 | + - "sys.resource_stats_TSQL" |
| 17 | + - "resource_stats_TSQL" |
| 18 | +dev_langs: |
| 19 | + - "TSQL" |
| 20 | +helpviewer_keywords: |
| 21 | + - "sys.resource_stats" |
| 22 | + - "resource_stats" |
| 23 | +ms.assetid: |
| 24 | +author: jovanpop-msft |
| 25 | +ms.author: jovanpop |
| 26 | +manager: craigg |
| 27 | +--- |
| 28 | +# sys.server_resource_stats (Azure SQL Database) |
| 29 | +[!INCLUDE[tsql-appliesto-xxxxxx-asdb-xxxx-xxx-md](../../includes/tsql-appliesto-xxxxxx-asdb-xxxx-xxx-md.md)] |
| 30 | + |
| 31 | +Returns CPU usage, IO, and storage data for an Azure SQL Managed Instance. The data is collected and aggregated within five-minute intervals. There is one row for every 15 seconds reporting. The data returned includes CPU usage, storage size, IO utilization, and managed instance SKU. Historical data is retained for approximately 14 days. |
| 32 | + |
| 33 | +The **sys.server_resource_stats** view has different definitions depending on the version of the Azure SQL managed instance that the database is associated with. Consider these differences and any modifications your application requires when upgrading to a new server version. |
| 34 | + |
| 35 | + |
| 36 | + The following table describes the columns available in a v12 server: |
| 37 | + |
| 38 | +|Columns|Data Type|Description| |
| 39 | +|----------------------------|---------------|-----------------| |
| 40 | +|start_time|**datetime2**|UTC time indicating the start of the fifteen-second reporting interval| |
| 41 | +|end_time|**datetime**|UTC time indicating the end of the fifteen-second reporting interval| |
| 42 | +|resource_type|Nvarchar(128)|Type of the resource for which metrics are provided| |
| 43 | +|resource_name|nvarchar(128)|Name of the resource.| |
| 44 | +|sku|nvarchar(128)|Managed Instance Service Tier of the Instance. The following are the possible values: <br><ul><li>General Purpose</li></ul><ul><li>Business Critical</li></ul>| |
| 45 | +|hardware_generation|nvarchar(128)|Hardware generation identifier: such as Gen 4 or Gen 5| |
| 46 | +|virtual_core_count|int|Represents number of virtual cores per instance (8, 16 or 24 in Public Preview)| |
| 47 | +|avg_cpu_percent|decimal(5,2)|Average compute utilization in percentage of the limit of the Managed Instance service tier utilized by the instance. It is calculated as sum of CPU time of all resource pools for all databases in the instance and divided by available CPU time for that tier in the given interval.| |
| 48 | +|reserved_storage_mb|bigint|Reserved storage per instance (amount of storage space that customer purchased for the managed instance)| |
| 49 | +|storage_space_used_mb|decimal(18,2)|Storage used by all managed instance databases’ files (including both user and system databases)| |
| 50 | +|io_request|bigint|Total number of i/o physical operations within the interval| |
| 51 | +|io_bytes_read|bigint|Number of physical bytes read within the interval| |
| 52 | +|io_bytes_written|bigint|Number of physical bytes written within the interval| |
| 53 | + |
| 54 | + |
| 55 | +> [!TIP] |
| 56 | +> For more context about these limits and service tiers, see the topics [Managed Instance service tiers](https://docs.microsoft.com/en-us/azure/sql-database/sql-database-managed-instance#managed-instance-service-tier). |
| 57 | + |
| 58 | +## Permissions |
| 59 | + This view is available to all user roles with permissions to connect to the **master** database. |
| 60 | + |
| 61 | +## Remarks |
| 62 | + The data returned by **sys.server_resource_stats** are expressed as the total used in either bytes or megabytes (stated in column names) other than avg_cpu, which is expressed as a percentage of the maximum allowed limits for the service tier/performance level that you are running. |
| 63 | + |
| 64 | +## Examples |
| 65 | + The following example returns all databases that are averaging at least 80% of compute utilization over the last one week. |
| 66 | + |
| 67 | +```sql |
| 68 | +DECLARE @s datetime; |
| 69 | +DECLARE @e datetime; |
| 70 | +SET @s= DateAdd(d,-7,GetUTCDate()); |
| 71 | +SET @e= GETUTCDATE(); |
| 72 | +SELECT resource_name, AVG(avg_cpu_percent) AS Average_Compute_Utilization |
| 73 | +FROM sys.server_resource_stats |
| 74 | +WHERE start_time BETWEEN @s AND @e |
| 75 | +GROUP BY resource_name |
| 76 | +HAVING AVG(avg_cpu_percent) >= 80 |
| 77 | +``` |
| 78 | + |
| 79 | +## See Also |
| 80 | + [Managed Instance service tiers](https://docs.microsoft.com/en-us/azure/sql-database/sql-database-managed-instance#managed-instance-service-tier) |
0 commit comments