如何以编程方式访问Azure Functions使用情况指标? [英] How can I programmatically access Azure Functions usage metrics?
问题描述
我想为基于消耗的Azure函数检索粒度GB/秒的使用情况数据.我该怎么办?
I would like to retrieve granular GB/sec usage data for my consumption based Azure Functions. How can I do this?
推荐答案
使用数据可通过Azure Monitor REST API获得.有关如何使用此API的一般概述,请参见
The usage data is available through the Azure Monitor REST API. For a general overview of how to use this API, see here.
相关度量标准是FunctionExecutionUnits
.此单位以MB毫秒为单位,因此要将其转换为GB-秒,您需要将值除以1,024,000.这是一个示例查询,它检索功能应用程序的每分钟使用情况数据:
The relevant metric is FunctionExecutionUnits
. This unit is in MB-milliseconds so to convert it into GB-seconds you need to divide the values by 1,024,000. Here is an example query retrieving per-minute usage data for a function app:
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')
您将获得类似这样的信息:
You'll get back something like this:
{
"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"
}
]
}
这篇关于如何以编程方式访问Azure Functions使用情况指标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!