【问题标题】:azure function failure alert gets triggered when success成功时触发天蓝色功能失败警报
【发布时间】:2020-11-11 16:05:47
【问题描述】:

我遇到了一个问题,即在执行 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)
        }
} 
}

编辑 ,正如评论中所要求的,这里是它的图片。

并成功执行:

【问题讨论】:

  • 您是否通过 azure monitor 设置了警报?如果您通过 UI 配置警报,可以分享一些屏幕截图吗?
  • 我是通过 azure 资源管理器设置的,
  • 哦,我不熟悉资源管理器。但是如果你可以通过 UI 使用 azure monitor 来设置它,我可以提供一些想法。
  • 我添加了图片
  • 是的,切换到它可能是一个更好的主意。首先,我将完成一些我仍然需要对我的函数应用程序进行的修改,然后检查自定义搜索日志以及警报如何使用它。感谢您的意见:)

标签: node.js azure azure-functions azure-alerts


【解决方案1】:

如果你的Azure函数与Application Insights关联,那么我建议你可以使用Custom log search(你可以参考this article。)。

这种信号的好处是应用洞察查询将显示我们需要的确切结果,并且我们清楚地知道逻辑。但是对于预定义的信号,我们并不清楚它在 beckend 中的逻辑。

请试一试,如果有任何问题,请告诉我。

【讨论】:

    猜你喜欢
    • 2023-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-22
    • 2020-11-20
    • 1970-01-01
    • 1970-01-01
    • 2020-03-22
    相关资源
    最近更新 更多