I have some node.js based Lambdas that are logging data.
In order to properly query and filter the data etc, I want to log as pure JSON data from my Lambdas.
However, when I do a regular console.log
it makes an ordinary string of the data.
console.log({a:1,b:2,x:"xxx"})
Results in this:
2020-04-29T14:46:45.722Z 3f64c499-fbae-4a84-996c-5e5f0cb5302c INFO { a: 1, b: 2, x: 'xxx' }
The logged line above does not seem to be searchable as JSON using the various filter matching options in CloudWatch.
I've tried to call the AWS.CloudWatchLogs
API directly but since I'm using lambda I cannot maintain a token between invocations of the functions, so I'm not sure that's the way to go.
Have anyone else had success in logging raw JSON from a Javascript Lambda?