0

我有一个运行 .NET Core API 的 AWS Lambda 函数。我已将其设置为将信息和错误记录到 CloudWatch。这行得通。例如,当发生错误时,我会在 CloudWatch Logs 中看到类似的内容。

2021-08-16T16:24:58.693-04:00 [Error] MyCompany.Api.Startup: Test global error handling.

我按照此处的示例设置了一个 CloudWatch 警报,该警报由 Lambda 中的应用程序错误触发。这是我生成的源代码:

{
    "Type": "AWS::CloudWatch::Alarm",
    "Properties": {
        "AlarmName": "API Lambda Error Alarm",
        "ActionsEnabled": true,
        "OKActions": [],
        "AlarmActions": [
            "arn:aws:sns:us-east-1:824088652971:Default_CloudWatch_Alarms_Topic"
        ],
        "InsufficientDataActions": [],
        "MetricName": "Errors",
        "Namespace": "AWS/Lambda",
        "Statistic": "Sum",
        "Dimensions": [
            {
                "Name": "FunctionName",
                "Value": "p-mycompany-api-lambda"
            },
            {
                "Name": "Resource",
                "Value": "p-mycompany-api-lambda"
            }
        ],
        "Period": 900,
        "EvaluationPeriods": 1,
        "DatapointsToAlarm": 1,
        "Threshold": 1,
        "ComparisonOperator": "GreaterThanOrEqualToThreshold",
        "TreatMissingData": "missing"
    }
}

但是,当我的 API 发生错误并写入 CloudWatch 时,永远不会触发警报。它甚至没有显示它发生在警报下。

我错过了什么?我配置错了吗?

4

0 回答 0