首页 > 解决方案 > 如果 X% 的请求失败,Azure Web App Service 会触发警报

问题描述

如果 X% 的请求在过去 24 小时内失败,我一直在尝试设置托管在 Azure 中的 .NET Core App Service 的警报以触发事件。我还尝试使用以下指标从服务的 AppInsights 资源设置警报:异常率、服务器异常或失败请求。

但是,这些都没有能力捕获 a % (failure rate),它们都被count用作度量。

有谁知道这个的解决方法?

标签: azureazure-application-insightsazure-web-app-service

解决方案


请尝试基于查询的警报:

1.转到应用程序洞察分析,在查询编辑器中,输入以下脚本:

exceptions
| where timestamp >ago(24h)
| summarize exceptionsCount = sum(itemCount) | extend t = ""| join
(requests 
| where timestamp >ago(24h)
| summarize requestsCount = sum(itemCount) | extend t = "") on t
| project isFail = 1.0 * exceptionsCount / requestsCount > 0.5 // if fail rate is greater than 50%, fail
| project rr = iff(isFail, "Fail", "Pass")
| where rr == "Fail"

2.然后点击右上角的“新建警报规则”:

在此处输入图像描述

3.在创建规则页面,设置如下:

在此处输入图像描述


推荐阅读