Unable to Access [Guest] metrics using Get-AzureRmMetric

♀尐吖头ヾ 提交于 2019-12-02 11:43:59

For now, Azure PowerShell does not support to use Get-AzureRmMetric to get memory usage metrics.

We can use Get-AzureRmMetricDefinition to get the supported metrics:

Here are the metrics for Azure VM:

PS D:\testdata> (Get-AzureRmMetricDefinition -ResourceId $id).name

Value                     LocalizedValue
-----                     --------------
Percentage CPU            Percentage CPU
Network In                Network In
Network Out               Network Out
Disk Read Bytes           Disk Read Bytes
Disk Write Bytes          Disk Write Bytes
Disk Read Operations/Sec  Disk Read Operations/Sec
Disk Write Operations/Sec Disk Write Operations/Sec
CPU Credits Remaining     CPU Credits Remaining
CPU Credits Consumed      CPU Credits Consumed

About supported metrics of Azure VM, please refer to this official article.

Then we can use the value to get other metrics:

Get-AzureRmMetric -ResourceId $id -TimeGrain 00:01:00 -DetailedOutput -MetricNames "Network in"

Here is my PowerShell output:

As a workaround, we can use OMS to get the Memory usage, more information about configuring performance counters on OMS, please refer to this link.


Update:

You are right, we can run this command on Azure PowerShell version 3.4.0, it works fine.

When we run this command on Version 3.4.0, we will get this warning:

WARNING: API deprecation: The use of the legacy metrics API will be discontinued in the next release. This implies a change in the call and the output of this cmdlet. Here is the PowerShell output:

As a workaround, we can via the REST API to export metrics, more information about it, please refer to this link.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!