简体   繁体   English

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

[英]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?有没有办法跨时间获取应用程序的实例数?

After selecting any metric from the given options we can add another filter.从给定选项中选择任何指标后,我们可以添加另一个过滤器。 As shown below.如下所示。

添加过滤器

Then we can add the "Instance" property and choose all the instances currently running for the function app.然后我们可以添加“实例”属性并选择当前为函数应用运行的所有实例。 As shown below.如下所示。

选择实例

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.此外,为了避免应用洞察定价影响,请在了解扩展行为后考虑禁用配置参数。

I just found it very easy using the portal.我只是发现使用门户网站非常容易。 You can switch the view for local and UTC time as well.您也可以切换本地时间和 UTC 时间的视图。 It tells you that how many instances were running at a particular time for your functiton app.它告诉您在特定时间为您的功能应用程序运行了多少个实例。 Try this out.试试这个。 在此处输入图像描述

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

相关问题 如何通过memory监控EC2实例? - How to monitor EC2 instances by memory? 从 Azure Container Registry 拉取镜像到 Azure Container Instances 时如何使用 SystemAssigned identity? - How can I use a SystemAssigned identity when pulling an image from Azure Container Registry into Azure Container Instances? 如何使用 Google Cloud Function 启动和停止 vm 实例? - How can I use a Google Cloud Function to start and stop vm instances? 如何访问我的 App Engine 应用程序每小时/每天/每周返回的错误数? - How can I access the number of errors that my App Engine app is returning per hour/day/week? 如何在 azure function 应用程序中终止 orchestrator function - how can I terminate an orchestrator function in azure function app Google Cloud Platform:如何监控 memory VM 实例的使用情况 - Google Cloud Platform: how to monitor memory usage of VM instances 当 EBS 实例空间不足时如何收到警报? - How can I be alerted when an EBS instance is running out of space? 如何在 2 个 ec2 实例上连接 2 个不同的 docker 容器? - How can I connect 2 different docker containers on 2 ec2 instances? 如何将相同的域名分配给 2 个 App Engine 实例? - How do I assign the same domain name to 2 App Engine Instances? Pulumi:如何从 Azure 中的 Function 应用程序中检索 function 名称? - Pulumi: How can I retrieve function names from a Function App in Azure?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM