Unable to get Azure monitoring metrics from the REST API

旧巷老猫 提交于 2019-12-11 04:37:27

问题


I retrieve metric definitions using this:

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

which returns

{
"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",

....

But when I attempt to fetch metric "\\Memory\\AvailableMemory" with

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

I get an error message:

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

The filter param in the URL is

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


This isn't a supported resource type through metrics API. The supported types and metrics are here. https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-supported-metrics

The Memory metric is a guest agent metric and will be written to WADMetrics table in customer storage account. The metric definition API returns back a SAS key to these tables but there is no metrics REST API to access this data today. Customer will need to access this data through storage APIs.



来源:https://stackoverflow.com/questions/43288846/unable-to-get-azure-monitoring-metrics-from-the-rest-api

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