我有一个问题,即在执行 azure 函数时会触发 azure 警报。我查看了不同的文档,查看了警报规则,查看了代码,但似乎我无法指出问题所在。你们可以检查一下我错过了什么吗?
警报的条件如下:
"criteria": {
"odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria",
"allOf": [
{
"name": "1st criterion",
"metricName": "<functionName> Failures",
"metricNamespace": "Azure.ApplicationInsights",
"dimensions": [
],
"operator": "GreaterThan",
"threshold": "0",
"monitorTemplateType": "8",
"criterionType": "StaticThresholdCriterion",
"timeAggregation": "PT1M",
"skipMetricValidation": true
}
]
},
"autoMitigate": true,
代码的相关部分:
module.exports = async function (context, req) {
try{
let res = await apicall();
response = {
status: 200, /* Defaults to 200 */
body: res
}
}catch(error){
response = {
status: 500, /* Defaults to 500 */
body: errorHandler(error)
};
errorObj = error
}finally{
if (response.status == 200) {
context.done(null, response)
} else {
context.done(errorObj, response)
}
}
}
并成功执行: