问题描述
我使用以下方法检索指标定义:
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
返回
{
"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"时
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
我收到一条错误消息:
{"code":"NotFound","message":"Please make sure your provider: Microsoft.ClassicCompute is properly registered with insights and retry"}
URL中的过滤器参数为
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'
推荐答案
这不是度量标准API支持的资源类型.支持的类型和指标在这里. https://docs.microsoft.com/zh-CN/azure/监测和诊断/监测支持的指标
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
内存"度量标准是来宾代理"度量标准,将被写入客户存储帐户中的WADMetrics表.指标定义API将SAS密钥返回给这些表,但是今天没有指标REST API可以访问此数据.客户将需要通过存储API访问此数据.
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.
这篇关于无法从REST API获取Azure监视指标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!