3
votes

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

1 Answers

0
votes

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.