Datadog parse array of json

Viewed 1120

I have array of json`s as log in Datadog. Example:

[{name:"jon"} , {name:"mike"}]

How can I parse inner json`s?

1 Answers

Not sure if parsing is the right word here.

Logs Management from DD is there to help analysing logs to help build insights about the app.

so, the question here. what kind of insight are you looking for?

let me come up with one. Given that the log payload is:

{
   users: [{ name: "Jon" }, { name: "Mike" }]
}

you want to list all the names included in each log, so, later on, you can look up for all the logs that have a user with the name of "Mike"

then, you can add a String Builder Processor to your pipeline. where it will lookup for every item in the array and map it to another attribute.

enter image description here

this will generate a new attribute of payload.result holds the names separated by ,

result: Jon, Mike

then, you can create a facet for this attribute and lookup for it ex. given the facet's name is @payload.result

@payload.result:*Mike*
// or
@payload.result:*Jon*

PS. processors help you reshape the payload of a log to pretty much any format. of course, it can get complicated. https://docs.datadoghq.com/logs/log_configuration/processors/?tab=ui

Related