5
我想检索基于消费的Azure函数的粒度GB /秒使用数据。我怎样才能做到这一点?如何以编程方式访问Azure功能使用指标?
我想检索基于消费的Azure函数的粒度GB /秒使用数据。我怎样才能做到这一点?如何以编程方式访问Azure功能使用指标?
使用数据可通过Azure监控REST API获得。有关如何使用此API的一般概述,请参阅here。
相关度量标准为FunctionExecutionUnits
。这个单位是MB毫秒,所以要将它转换成GB-seconds,你需要将值除以1,024,000。下面是一个函数应用的例子查询检索每分钟使用量数据:
GET /subscriptions/<subid>/resourcegroups/<rg>/providers/Microsoft.Web/sites/<appname>/providers/microsoft.insights/metrics?api-version=2016-06-01&$filter=(name.value eq 'FunctionExecutionUnits') and timeGrain eq duration'PT1M' and startTime eq 2016-12-10T00:00:00Z and endTime eq 2016-12-10T00:05:00Z and (aggregationType eq 'Total')
你会得到这样的事情:
{
"value": [
{
"data": [
{
"timeStamp": "2016-12-10T00:00:00Z",
"total": 0
},
{
"timeStamp": "2016-12-10T00:01:00Z",
"total": 140544
},
{
"timeStamp": "2016-12-10T00:02:00Z",
"total": 0
},
{
"timeStamp": "2016-12-10T00:03:00Z",
"total": 0
},
{
"timeStamp": "2016-12-10T00:04:00Z",
"total": 0
}
],
"name": {
"value": "FunctionExecutionUnits",
"localizedValue": "Function Execution Units"
},
"type": "Microsoft.Insights/metrics",
"unit": "0"
}
]
}