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"
}
]
}