我正在尝试在应用程序洞察中创建警报,如果超过5%的请求超过某个阈值,它将提醒我 . 我在Application Insights的警报部分编写了一个查询,并将其指定为度量标准测量,以便在超过所需阈值时发出警报
requests
| where timestamp >= ago(15m)
| where (tostring(customDimensions['ProviderName']) == 'ProviderX')
| where (tostring(customDimensions['operationMethod']) == 'operationX')
| extend responseTime = tolong(customDimensions['totalMilliseconds'])
| summarize AggregatedValue = (percentile(responseTime, 95)) by bin(timestamp, 15m)
虽然这个警报有效并且正确通知我,但由于在某些15分钟的窗口中存在非常少量的请求(少于3个),因此存在大量误报 . 因此,我只想在超过阈值的值时发出警报,并且该时间段内的相关请求的数量超过某个阈值,例如10 .
我尝试使用应用程序洞察的警报部分中的“结果警报数”来执行此操作 .
requests
| where timestamp >= ago(15m)
| where (tostring(customDimensions['ProviderName']) == 'ProviderX')
| where (tostring(customDimensions['operationMethod']) == 'OpeartionX')
| extend responseTime = tolong(customDimensions['totalMilliseconds'])
| summarize hasFailed = ((percentile(responseTime, 95) > 1000) and count() > 135)
| project iff(hasFailed, 1, 0)
我试图实现的是,如果测试失败,则将警报返回1,然后对此值发出警报 . 但是,“结果数”似乎只是警告返回的结果数,因此这种方法也不起作用 .
如果有人可以对适当的查询或如何在Azure上实现此问题的替代策略有所了解,我将非常感激 .
谢谢 .
1 回答
如果您想使用阈值警报,我可以用以下内容替换您的第一个查询:
如果您更喜欢"Number of Results Alert"方法,我认为您可以使用
| where hasFailed == true
替换第二个查询的最后一行,以便在满足条件时最终得到一行,而在不符合条件时则为零行 .