Get-AzMetric

In this Azure PowerShell article, we will discuss the syntax and usage of the Get-AzMetric Azure PowerShell command with certain examples.

Get-AzMetric

This PowerShell command can help you to 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]

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 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

Get-AzMetric

Example-2

You can execute the below Azure PowerShell command to get a metric of the specified Azure Resource with detailed output.

get-azmetric -ResourceId "/subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/MyNewResGrp/providers/microsoft.web/sites/TsInfoweb" -DetailedOutput

After executing the above PowerShell command, I got the expected output as shown below.

get-azmetric examples

Get-AzMetric PowerShell – Video Tutorial

Conclusion

In this Azure PowerShell article, we discussed the syntax and usage of the Get-AzMetric Azure PowerShell command with certain examples. Thanks for reading this article !!!