Unable to Access [Guest] metrics using Get-AzureRmMetric

前端 未结 1 1561
孤城傲影
孤城傲影 2021-01-29 04:12

I have guest-level metrics enable for an Azure Virtual Machine and am trying to get the history for the [Guest]\\Memory\\Committed Bytes property using Ge

相关标签:
1条回答
  • 2021-01-29 04:37

    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.

    0 讨论(0)
提交回复
热议问题