Azure Resource utilization metrics information through Power shell

This article has been updated to use the new Azure PowerShell Az module. To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. For installation instructions, see Install Azure PowerShell.

To prepare to use PowerShell, download and install the Azure PowerShell cmdlets. See How to install and configure Azure PowerShellfor the install point and installation instructions.

Note: It’s recommended that you download and install or upgrade to the latest Azure PowerShell module.

Azure resource utilization provides several ways to interact with metrics, including charting them in the portal, accessing them through the REST API, or querying them using PowerShell or CLI. Below is a complete list of all metrics currently available with Azure Monitor's metric using PowerShell.

Metric = Percentage CPU

Aggregation = AVG

# Get the virtual machine details

$vm = Get-AZvm -ResourceGroupName "<resourcegroup>" -Name "<VMname>"

# Get the resource ID for the virtual machine

$resourceID = $vm.Id

This provides the complete details of AVG Percentage CPU metric information for last 1 hour time stamp.

Get-AzMetric –ResourceId $resourceID -DetailedOutput|select -ExpandProperty data| sort timestamp |format-table *

Additional information:  How Metrics work for the Tables Storage?

 If you are having trouble understanding the metrics with the "(sum)" suffix in the bottom row of your chart. This is an aggregate over the entire chart duration unless your mouse is hovering inside the chart area. If the mouse is in the chart area, those values will usually change to give you instant values from the time at the x axis value under the mouse.

You have likely chosen the aggregation to be "sum" in which case it will total up the approximately 10 MB or so usage detected every hour over the course of the last 24 hours to arrive at that number which is close to 240MB. While this aggregation is not helpful for usage metrics such as these, they are useful when, say, you want to know total transactions over the last 24 hours. 

Storage Analytics Metrics Table Schema

Additional information: With metrics on Azure Storage, you can analyze usage trends, trace requests, and diagnose issues with your storage account.

Azure Monitor provides unified user interfaces for monitoring across different Azure services. For more information, see Azure Monitor. Azure Storage integrates Azure Monitor by sending metric data to the Azure Monitor platform.

Online peer support: For online peer support, join The Official Scripting Guys Forum! To provide feedback or report bugs in sample scripts, please start a new discussion on the Discussions tab for this script.