Application Insights Alert用于自定义查询

时间:2018-08-20 09:13:59

标签: azure-application-insights

目标: 设置警报,以特定的Analytics(分析)查询结果触发(按汇总值)。但是通知不会触发。

此请求每隔5分钟返回一次结果。 每个AggregatedValue都小于100。

let apdexThreshhold = toint('1000');
let apdexData = requests
| where timestamp > ago(1d)
| where url contains "GetProcessModel"
| where customDimensions.workspace == "di"
| where customDimensions.processname == "travelinsurance"
| where customDimensions.widgetname == "TravelSegmentationStep"
| where customDimensions.actionname == "computeCostAction" or customDimensions.accessModifier == "action=computeCostAction"
 //("POST Insurance/PostModel [actionName/elementid/widgetname/workspace]")
| extend success = columnifexists('success', true)
| extend Failure = iff(success == false, 1, 0)
| extend UserExperience = case(duration <= apdexThreshhold, 'Satisfied', duration <= 4 * apdexThreshhold, 'Tolerating', 'Frustrated')
| summarize Satisfied = countif(UserExperience == 'Satisfied'), Tolerating = countif(UserExperience == 'Tolerating'), Frustrated = countif(UserExperience == 'Frustrated' or  Failure == 1), Total = count(), AverageDuration = avg(duration) by bin(timestamp, 5m)
| project ["Satisfied Users"] = Satisfied, ["Tolerating Users"] = Tolerating, ["Frustrated Users"] = Frustrated, ["Apdex Score"] = round((Satisfied + (Tolerating / 2.0)) / Total, 2), Total, AverageDuration, timestamp 
| extend Relevance = iff(["Apdex Score"] == 0, pow(Total, 1.6), Total / ["Apdex Score"])
| project-rename Users = Total
| project-away Users, Relevance;
apdexData
| extend ["Apdex Interpretation"] = case(["Apdex Score"] <= 0.5, '⛔ Unacceptable', ["Apdex Score"] <= 0.7, '⚠️ Poor', ["Apdex Score"] <= 0.85, '⚠️ Fair', ["Apdex Score"] <= 0.94, '✔️ Good', '✔️ Excellent')
| project ["Apdex Score"], ["Apdex Interpretation"], ["Satisfied Users"], ["Tolerating Users"], ["Frustrated Users"], apdexThreshhold, AverageDuration, timestamp 
| summarize  AggregatedValue = avg(["Apdex Score"]) * 100 by bin(timestamp, 5m)
| order by timestamp 

警告逻辑:

基于:度量标准

条件:小于

阈值:100

触发警报基于:

违规总数大于0

汇总时间戳记

评估依据:

期间:过去一个小时

频率:每5分钟

0 个答案:

没有答案
相关问题