[英]Amazon Cloudwatch log filtering - JSON syntax
I have an AWS Lambda function which is logging errors. 我有一个AWS Lambda函数,它记录错误。 Errors are logged as such:
错误记录如下:
console.error(err);
I'm trying to create a Cloudwatch filter which uses their JSON log filtering syntax: 我正在尝试创建一个使用其JSON日志过滤语法的Cloudwatch过滤器:
{ $.errorType = "ValidationException" }
I can see the error in the log 我可以在日志中看到错误
2015-11-24T20:26:02.852Z 76800706-2d78-45ed-9068-46ccccafe6af { "errorMessage": "1 validation error detected: Value '[]' at 'xxxxxx' failed to satisfy constraint: Member must have length greater than or equal to 1", "errorType": "ValidationException", "stackTrace": [ ...etc... ] }
Is there some sort of special setup or manual logging into CloudWatch required to support the JSON filter syntax? 是否存在某种特殊设置或手动登录CloudWatch以支持JSON过滤器语法? I cannot find any info in the CloudWatch docs.
我在CloudWatch文档中找不到任何信息。
Docs: 文档:
http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html
http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/FilterAndPatternSyntax.html#d0e19372 http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/FilterAndPatternSyntax.html#d0e19372
Seems like when you log from Lambda it turns everything in to a string. 似乎当您从Lambda登录时,它将所有内容都转换为字符串。 May have something to do with adding the Request time and ID to each item.
可能与为每个项目添加请求时间和ID有关。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.