Amazon Cloudwatch log filtering - JSON syntax

泄露秘密 提交于 2019-12-23 19:37:25

问题


I have an AWS Lambda function which is logging errors. Errors are logged as such:

console.error(err);

I'm trying to create a Cloudwatch filter which uses their JSON log filtering syntax:

{ $.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? I cannot find any info in the CloudWatch docs.

Docs:

http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-logging.html

http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/FilterAndPatternSyntax.html#d0e19372


回答1:


Seems like when you log from Lambda it turns everything in to a string. May have something to do with adding the Request time and ID to each item.



来源:https://stackoverflow.com/questions/33903735/amazon-cloudwatch-log-filtering-json-syntax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!