title: How to log raw JSON to Cloudwatch from AWS Lambda in node.js?
body: <p>I have some node.js based Lambdas that are logging data.</p>
  <p>In order to properly query and filter the data etc, I want to log as pure JSON data from my Lambdas.</p>
  <p>However, when I do a regular <code>console.log</code> it makes an ordinary string of the data.</p>
  <pre class="lang-js prettyprint-override"><code>console.log({a:1,b:2,x:&quot;xxx&quot;})
  </code></pre>
  <p>Results in this:</p>
  <pre><code>2020-04-29T14:46:45.722Z    3f64c499-fbae-4a84-996c-5e5f0cb5302c    INFO    { a: 1, b: 2, x: 'xxx' }
  </code></pre>
  <p>The logged line above does not seem to be searchable as JSON using the various filter matching options in CloudWatch.</p>
  <p>I've tried to call the <code>AWS.CloudWatchLogs</code> 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.</p>
  <p>Have anyone else had success in logging raw JSON from a Javascript Lambda?</p>