Vercel Datadog integration - parsing JSON logs?

I have Vercel’s integration setup in Datadog. My logs do stream through, but the log output just seems to be plaintext:

START RequestId: 9ea605db-6150-49c4-ab16-5401722a988a Version: $LATEST
{"level":30,"time":1724401439773,"pid":3,"hostname":"XXX","message":"This is a test info","method":"createSession"}
{"level":40,"time":1724401439774,"pid":3,"hostname":"XXX","message":"This is a test warning","method":"createSession"}
END RequestId: 9ea605db-6150-49c4-ab16-5401722a988a
REPORT RequestId: 9ea605db-6150-49c4-ab16-5401722a988a	Duration: 227.29 ms	Billed Duration: 228 ms	Memory Size: 1769 MB	Max Memory Used: 260 MB

Datadog logs this with status OK at INFO level with the log in plaintext so I can’t extract the attributes.

I noticed this thread: Sending JSON object to datadog with Vercel log drains integration · vercel · Discussion #139 · GitHub. Seems like the same thing, but it was locked without further clarification.

Any idea on how I can get the integration to parse the logs?

Hi @jrobt! :blush:

I understand you’re having some trouble with your logs coming through as plaintext instead of parsed JSON. That can definitely make it harder to extract and analyze specific attributes, but no worries—let’s see what we can do to help!

Here are a few things you might want to check out:

  1. Log Source Selection: Vercel lets you choose which log sources are sent to your log drain. Make sure you’ve selected the ones that best suit your needs, like static, lambda, edge, build, or external.
  2. Log Format: It looks like your logs contain JSON data within the plaintext output. The lines starting with {"level":...} are valid JSON, but they might be mixed in with other non-JSON lines (like START, END, and REPORT), which could be causing some parsing issues.
  3. Datadog Pipeline: You might want to set up a custom processing pipeline in Datadog to handle these logs more effectively. Since the JSON is valid within the plaintext, you could try using Datadog’s Grok Parser or JSON Parser to pull out the information you need.
  4. Vercel Configuration: Unfortunately, there’s no built-in option to change the log format on the Vercel side for Datadog integration at the moment.

I hope this helps!

Thank you.

Log source is lambda and that seems to be working fine for what I need.

I was hoping I wouldn’t have to make my own log pipeline. I had a look at making a Grok parser but I couldn’t get a regex which worked properly.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.