我一直试图设置Azure中托管的.NET Core App Service的警报,以在过去24小时内X%的请求失败时触发事件.我还尝试使用以下指标从服务的AppInsights资源中设置警报:异常率,服务器异常或请求失败.
I have been trying to set up alerts of a .NET Core App Service hosted in Azure to fire an event if X% of the requests are failing in the past 24 hours. I have also tried setting up an alert from the Service's AppInsights resource using the following metrics: Exception rate, Server exceptions, or Failed request.
但是,它们都不具有捕获% (failure rate)的能力,它们都使用count作为度量标准.
However, none of these have the ability to capture a % (failure rate), all of them are using count as a metric.
有人知道解决方法吗?
Does anyone know a workaround for this?
推荐答案请尝试基于查询的警报:
Please try the query-based alert:
1.转到应用程序见解分析,在查询编辑器中,输入以下脚本:
1.Go to application insights analytics, in the query editor, input below scripts:
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.然后单击右上角的新警报规则":
2.Then click the "New alert rule" on the upper right corner:
3.在创建规则"页面中,设置如下:
3.In the Create rule page, set as following:
更多推荐
如果X%的请求失败,则Azure Web App Service会触发警报
发布评论