我有一个记录错误的 AWS Lambda 函数。错误记录如下:
console.error(err);
我正在尝试创建一个使用其 JSON 日志过滤语法的 Cloudwatch 过滤器:
{ $.errorType = "ValidationException"}
我可以在日志中看到错误
2015-11-24T20:26:02.852Z 76800706-2d78-45ed-9068-46ccccafe6af
{
"errorMessage": "检测到 1 个验证错误:'xxxxxx' 的值 '[]' 无法满足约束:成员的长度必须大于或等于 1",
"errorType": "验证异常",
“堆栈跟踪”: [
...ETC...
]
}
是否需要某种特殊设置或手动登录 CloudWatch 来支持 JSON 过滤器语法?我在 CloudWatch 文档中找不到任何信息。
文档:
http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html
最佳答案
似乎当您从 Lambda 登录时,它会将所有内容都转换为字符串。可能跟给每个item加上Request时间和ID有关系。
关于json - Amazon Cloudwatch 日志过滤 - JSON 语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33903735/