我正在尝试针对以下情况构建警报:在 15 分钟的时间内,如果 FailedRequests 的数量大于收到的请求的 99%,我想发出警报。我已经编写了一个 KQL 查询,但不幸的是,即使没有发生真正的问题,即没有真正获得大于 99% 的条件,它也会触发。以下是查询,我确信我在其中犯了一些愚蠢的错误,有什么帮助吗?
修复上述查询的任何帮助,以便仅在关键时(即收到的所有请求都失败时)才真正给出结果。
requests
| where cloud_RoleName == 'ABCDEF_cloudRName' and resultCode != '404'
| summarize FailedPercent=((countif(success == false))/count() by timestamp, cloud_RoleName, appName)*100
| where FailedPercent > 99
| project RelatedCI='XYZZZ',AlarmTime=timestamp,Category="Cloud-Azure-Monitor",SubCategory="Application",Object=appName ,"Value of Metric","Percentage Failed Requests"," is ", FailedPercent
最佳答案
Here当失败百分比大于 xx% 时发送警报也是类似的问题。
我只是写了一个查询,如果不符合您的需求,请随意修改:
requests
| where resultCode != "404" and success == "False"
| summarize exceptionsCount =count()
| extend a = "a"
| join
(
requests
| where resultCode != "404"
| summarize requestsCount =count()
| extend a = "a"
)
on a
| project isFail = 1.0 * exceptionsCount / requestsCount > 0.99 //check if the failed percentage is greater than 99%.
| project rr=iff(isFail, "Fail","Pass" )
| where rr=="Fail"
查询代码准备就绪后,您可以按照 issue 中的步骤创建基于查询的警报。如上所述。
关于azure - 查询以获取失败请求的百分比 Azure Application Insights,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56468701/