0

我正在发送 Postman 请求以从事件网格中获取指标,如下所示:

https://management.azure.com/subscriptions/{suscription id}/resourceGroups/{name of resource group}/providers/microsoft.insights/metricDefinitions/?api-version=2018-01-01

我还附加了 Bearer 令牌。

但是,我不断收到以下回复:

{
    "message": "An error has occurred.",
    "exceptionMessage": "ApiVersion: 2018-01-01 does not support query at non Arm resource Id level",
    "exceptionType": "Microsoft.Online.Metrics.MetricsMP.Utilities.RPRequestFormatException",
    "stackTrace": "   at Microsoft.Online.Metrics.MetricsMP.Controllers.MPController_MetricDefinitions_Base.<MetricDefinitionAtResourceGroup>d__4.MoveNext() in ...
                    ....
}

这是什么意思,我该如何解决?我一直在互联网上寻找,并没有太多信息。

4

3 回答 3

2

你的网址是错误的。据我所知,如果你想检索指标定义,剩下的 api 就是

方法:获取

请求 URI: https ://management.azure.com/subscriptions/ {subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/microsoft.insights/metricDefinitions?api-version ={api版本}

更多详情,请参阅

https://docs.microsoft.com/en-us/rest/api/monitor/metricdefinitions/metricdefinitions_list https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-rest-api -演练

于 2018-10-18T07:15:33.073 回答
1

您错过了请求 url 中的资源类型和名称,该 url 应如下所示:

https://management.azure.com/{resourceUri}/providers/microsoft.insights/metricDefinitions

参考:https ://docs.microsoft.com/en-us/rest/api/monitor/metricdefinitions/list

如果您想列出事件网格的指标定义,您的 url 应该是:

GET https://management.azure.com/subscriptions/{subscription id}/resourceGroups/{resource group name}/providers/Microsoft.EventGrid/topics/{event grid topic name}/providers/microsoft.insights/metricDefinitions?api-version=2018-01-01

测试结果:

在此处输入图像描述

于 2018-10-19T01:27:48.890 回答
1

要获取指标定义,请使用这个 rest API

https://management.azure.com/subscriptions/ {subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resource ProviderNamespace}/{resource Type}/{resourceName}/providers/microsoft.insights/metricdefinitions?api-version= 2018-01-01

要获取带有可选参数的指标,请使用此 REST API

https://management.azure.com/subscriptions/ {subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/metrics?timespan={timeSpan}&interval={timeGranularity}&aggregation={AggregationType}&metricnames={metricName} &api-版本=2018-01-01

于 2018-10-18T11:52:17.277 回答