无法从REST API获取Azure监控指标

时间:2017-04-08 00:21:23

标签: azure monitoring

我使用以下方法检索指标定义:

https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-grp-id}/providers/microsoft.classiccompute/virtualMachines/{vm-id}/providers/microsoft.insights/metricdefinitions?api-version=2015-07-01

返回

{
"id": "/subscriptions/{subscription-id}/resourceGroups/{res-group-id}/providers/microsoft.classiccompute/virtualMachines/{vm-id}/providers/microsoft.insights/metricdefinitions",
"value": [
    {
        "resourceUri": "/subscriptions/{subscription-id}/resourceGroups/{res-group-id}/providers/Microsoft.ClassicCompute/virtualMachines/{vm-id}",
        "resourceId": "/subscriptions/{subscription-id}/resourceGroups/{res-group-id}/providers/Microsoft.ClassicCompute/virtualMachines/{vm-id}",
        "name": {
            "value": "\\Memory\\AvailableMemory",
            "localizedValue": "Memory available"
        },
        "startTime": "0001-01-01T00:00:00Z",
        "endTime": "0001-01-01T00:00:00Z",
        "unit": "Bytes",
        "primaryAggregationType": "Average",
        "ResourceUri": "/subscriptions/{subscription-id}/resourceGroups/{res-group-id}/providers/Microsoft.ClassicCompute/virtualMachines/{vm-id}",
        "ResourceId": "/subscriptions/{subscription-id}/resourceGroups/{res-group-id}/providers/Microsoft.ClassicCompute/virtualMachines/{vm-id}",
        "metricAvailabilities": [a11bbc020fdd/resourceGroups/cldy-az-res-grp-test-1/providers/Microsoft.ClassicCompute/virtualMachines/cldy-az-vm-test-1","metricAvailabilities":[{"timeGrain":"PT1H","retention":"P10675199DT2H48M5.4775807S","location":{"tableEndpoint":"https://cldyazresgrptest19563.table.core.windows.net/","tableInfo":[{"tableName":"WADMetricsPT1HP10DV2S20170331",

...

但是当我尝试获取指标" \\ Memory \\ AvailableMemory"与

https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{res-grp-id}/providers/Microsoft.ClassicCompute/virtualMachines/{vm-id}/providers/microsoft.insights/metrics?api-version=2016-09-01&$filter=%28name.value+eq+%27%5CMemory%5CAvailableMemory%27%29+and+aggregationType+eq+%27Average%27+and+startTime+eq+2017-04-06T10%3A01%3A00Z+and+endTime+eq+2017-04-07T10%3A01%3A00Z+and+timeGrain+eq+duration%27PT1H%27

我收到错误消息:

{"code":"NotFound","message":"Please make sure your provider: Microsoft.ClassicCompute is properly registered with insights and retry"}

网址中的过滤器参数是

(name.value eq '\Memory\AvailableMemory') and aggregationType eq 'Average' and startTime eq 2017-04-06T10:01:00Z and endTime eq 2017-04-07T10:01:00Z and timeGrain eq duration'PT1H' 

1 个答案:

答案 0 :(得分:1)

这不是通过指标API支持的资源类型。支持的类型和指标在这里。 https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-supported-metrics

内存指标是来宾代理指标,将写入客户存储帐户中的WADMetrics表。度量标准定义API将SAS密钥返回给这些表,但是今天没有用于访问此数据的度量标准REST API。客户需要通过存储API访问此数据。