繁体   English   中英

扩展时如何监控 function 应用程序的实例数?

[英]How can I monitor number of instances of a function app when it scales out?

我正在 Azure 门户中查看我的 function 应用程序的“指标”选项卡(平台功能 -> 指标)。 我可以看到有趣的指标,如 CPU 时间、请求计数等,但没有指标可以显示应用程序已扩展到的实例数。

在此处输入图像描述

有没有办法跨时间获取应用程序的实例数?

从给定选项中选择任何指标后,我们可以添加另一个过滤器。 如下所示。

添加过滤器

然后我们可以添加“实例”属性并选择当前为函数应用运行的所有实例。 如下所示。

选择实例

一种方法是使用 App Insights 查询。 这将为您提供过去 24 小时内每 30 秒运行的不同实例的数量。

您可以根据自己的选择编辑粒度和时间跨度,但请记住,粒度越大,查询的准确度就越低,因为实例可以随时启动和关闭。

let grainTime = 30sec;

traces
| where timestamp >= ago(24h)
| summarize ['rate/minute'] = dcount(cloud_RoleInstance) by bin(timestamp, grainTime)
| render timechart

然后您可以将其固定到您的仪表板!

作为预览功能,现在我们可以让 scale controller 发出带有推理的日志,以帮助理解应用程序在不同点扩展的原因和方式。 您必须将 function 配置添加为SCALE_CONTROLLER_LOGGING_ENABLED=AppInsights:Verbose 然后您可以查询您的规模 controller 日志以了解此 Microsoft 文档中的原因和实例计数。

我修改了链接文档中的 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 

在此处输入图像描述

您还可以将 controller 规模的日志发送到 Blob 存储。 在上面的示例中,我选择了 AppInsights 进行快速查询。 此外,为了避免应用洞察定价影响,请在了解扩展行为后考虑禁用配置参数。

我只是发现使用门户网站非常容易。 您也可以切换本地时间和 UTC 时间的视图。 它告诉您在特定时间为您的功能应用程序运行了多少个实例。 试试这个。 在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM