amazon-web-services - 如何配置 CloudWatch 警报以捕获错误?
问题描述
我有一个运行 .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 时,永远不会触发警报。它甚至没有显示它发生在警报下。
我错过了什么?我配置错了吗?
解决方案
推荐阅读
- python - 我可以使用 sublime Text 构建系统在 docker 容器中执行 manage.py 命令吗?
- javascript - 如何在nodejs上使用对象json数据进行嵌套循环
- ios - 开始开发 iOS 应用程序 (Swift) - 添加按钮不再起作用
- python - 在 1 个串行上结合 2 个伺服器和传感器
- javascript - 使用 await 和 r2 等待 HTTP 响应,然后再进一步
- python - 我在 Python 3.6 中收到错误“os.chdir(saved_path) 处的无效错误”
- c# - 基于 Unity 网格的建筑(捕捉到网格)并在捕捉时跟随鼠标
- android - 构建 apk 失败并出现错误:包 android.arch.core.util 不存在
- python - 将 python 列表转换为 tsv 格式以便在 memsql 中输入
- html - 当我放大所有元素时,我希望页面在我放大时位于中心