This Azure PowerShell article discusses the syntax and usage of the Get-AzMetric Azure PowerShell command, providing specific examples.
Table of Contents
Get-AzMetric
This PowerShell command can help you retrieve the metric values of an Azure resource.
Syntax
Below is the syntax of the Get-AzMetric PowerShell command.
Get-AzMetric
[-ResourceId] <String>Get-AzMetric [-ResourceId] <String> [-TimeGrain <TimeSpan>] [-DetailedOutput]Examples
.Let’s discuss a few examples of how to use the Get-AzMetric PowerShell command.
Example-1
You can execute the below Azure PowerShell command to get a metric of the specified Azure Resource with a summarized output.
Get-AzMetric -ResourceId "/subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/MyNewResGrp/providers/microsoft.web/sites/TsInfoweb"After executing the above command, I got the below-expected output
Id : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/MyNewResGrp/providers/microsoft.web/sites/TsInfoweb/providers/Microsoft
.Insights/metrics/CpuTime
Name :
LocalizedValue : CPU Time
Value : CpuTime
Type : Microsoft.Insights/metrics
Unit : Seconds
Data : {Microsoft.Azure.Commands.Insights.OutputClasses.PSMetricValue, Microsoft.Azure.Commands.Insights.OutputClasses.PSMetricValue,
Microsoft.Azure.Commands.Insights.OutputClasses.PSMetricValue, Microsoft.Azure.Commands.Insights.OutputClasses.PSMetricValue...}
Timeseries : {Microsoft.Azure.Management.Monitor.Models.TimeSeriesElement}
You can see the same output below

Example-2
You can execute the command below in Azure PowerShell to retrieve a metric for the specified Azure Resource with detailed output.
get-azmetric -ResourceId "/subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/MyNewResGrp/providers/microsoft.web/sites/TsInfoweb" -DetailedOutputAfter executing the above PowerShell command, I got the expected output, as shown below.

Video Tutorial
Conclusion
In this Azure PowerShell article, we discuss the syntax and usage of the Get-AzMetric Azure PowerShell command, along with several examples. Thanks for reading this article !!!

I am Rajkishore, and I am a Microsoft Certified IT Consultant. I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machines, Logic Apps, PowerShell Commands, CLI Commands, Machine Learning, AI, Azure Cognitive Services, DevOps, etc. Not only that, I do have good real-time experience in designing and developing cloud-native data integrations on Azure or AWS, etc. I hope you will learn from these practical Azure tutorials. Read more.
