[英]How can I monitor number of instances of a function app when it scales out?
I am looking into "Metrics" tab (Platform Features -> Metrics) in Azure portal for my function app.我正在 Azure 门户中查看我的 function 应用程序的“指标”选项卡(平台功能 -> 指标)。 I can see interesting metrics like CPU time, request count, etc. but there is no metric that would show the number of instances that the app has scaled out to.
我可以看到有趣的指标,如 CPU 时间、请求计数等,但没有指标可以显示应用程序已扩展到的实例数。
Is there a way to get the number of instances of the app across time?有没有办法跨时间获取应用程序的实例数?
One way is to use an App Insights query.一种方法是使用 App Insights 查询。 This will give you the number of distinct instances running every 30 seconds for the last 24 hours.
这将为您提供过去 24 小时内每 30 秒运行的不同实例的数量。
You can edit the granularity and the time span as you choose but bear in mind that the larger granularity the less accurate the query will be as instances can spin up and wind down at any time.您可以根据自己的选择编辑粒度和时间跨度,但请记住,粒度越大,查询的准确度就越低,因为实例可以随时启动和关闭。
let grainTime = 30sec;
traces
| where timestamp >= ago(24h)
| summarize ['rate/minute'] = dcount(cloud_RoleInstance) by bin(timestamp, grainTime)
| render timechart
You can then pin this to your dashboard!然后您可以将其固定到您的仪表板!
As a preview feature , now we can have scale controller emit logs with reasoning to help understand why and how the application have scaled at various points.作为预览功能,现在我们可以让 scale controller 发出带有推理的日志,以帮助理解应用程序在不同点扩展的原因和方式。 You will have to add a function configuration as
SCALE_CONTROLLER_LOGGING_ENABLED=AppInsights:Verbose
.您必须将 function 配置添加为
SCALE_CONTROLLER_LOGGING_ENABLED=AppInsights:Verbose
。 Then you can query your scale controller logs to know reason and instance count as in this microsoft docs .然后您可以查询您的规模 controller 日志以了解此 Microsoft 文档中的原因和实例计数。
I modified the kusto query in the linked document to have a function scaling graph for past 24 hours我修改了链接文档中的 kusto 查询,使其在过去 24 小时内具有 function 缩放图
traces
| where customDimensions.Category == "ScaleControllerLogs"
| where customDimensions.Action == "ScaleResult"
| where customDimensions.AppName == "my-function-app-name"
| extend currentInstanceCount = toint(customDimensions.CurrentInstanceCount)
| make-series rawInstanceCounts = max(currentInstanceCount) default=-1 on timestamp in range(ago(24h), now(), 5m)
| extend instanceCountsForwardFilled = series_fill_forward(rawInstanceCounts, -1)
| project timestamp, instanceCountsForwardFilled
| render timechart
You may also emit scale controller logs to Blob Storage.您还可以将 controller 规模的日志发送到 Blob 存储。 In the above example, I chose AppInsights for quick queries.
在上面的示例中,我选择了 AppInsights 进行快速查询。 Also to avoid app insights pricing impact, consider disabling the config parameter once you understood the scaling behaviour.
此外,为了避免应用洞察定价影响,请在了解扩展行为后考虑禁用配置参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.