https://management.azure.com/subscriptions/{subscription Id}/resourceGroups/{Resource Group}/providers/Microsoft.Sql/servers/{servername}/providers/microsoft.insights/metrics?api-version=2017-05-01-preview&$filter=(name.value eq 'dtu_consumption_percent' ) and startTime eq 2017-09-10 and endTime eq 2017-09-11 and timeGrain eq duration'PT1H'
上面是我传递的用于获取 sql server 指标数据的 url
我得到的回复是:
{
"cost": 0,
"timespan": "2017-09-12T03:56:27Z/2017-09-12T04:56:27Z",
"interval": "PT1M",
"value": [
{
"id": "/subscriptions/{subscription Id}/resourceGroups/{Resource Group}/providers/Microsoft.Sql/servers/{server name}/providers/Microsoft.Insights/metrics/dtu_consumption_percent",
"type": "Microsoft.Insights/metrics",
"name": {
"value": "dtu_consumption_percent",
"localizedValue": "DTU percentage"
},
"unit": "Percent",
"timeseries": []
}
]}
时间序列中没有数据。
可能是什么问题?
最佳答案
如果我不指定过滤器,当我使用“2017-05-01-preview”作为 API 版本时,可以返回 dtu_conspiration_percent
(默认指标)。
时间序列数据:
如果我将过滤器指定为您的过滤器并使用“2017-05-01-preview”作为 API 版本,则会收到 400 错误。
在 this article 中的“检索指标值”部分下,我发现:
Note
To retrieve metric values using the Azure Monitor REST API, use "2016-06-01" as the API version.
您可以尝试使用“2016-06-01”作为 API 版本来检索指标值。
关于json - 从 AZURE 检索 SQL Server 数据的指标值时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46168289/