Getting Data In

Extracting data from nested json payload of varying size

dhruv101
Path Finder

Hi,

I have events coming into splunk with payload of nested json array type.
The elements in the array are of the same format looking like -

{
type:'Foo',
time:'10 July'
}

But events may have variable number of these elements within the payload array. That means some event may have 10 elements within the payload array whereas some other may have just 1. Is there a way to efficiently handle extracting data from such variable size payloads in splunk? I saw some examples with spath but it looks like the expectation is to kinda have same fixed number of elements in the payload array.

Thanks.

0 Karma

MuS
SplunkTrust
SplunkTrust

Hi dhruv101,

best thing to do here is to use props.conf and transforms.conf to get this captured:

transforms.conf

[myTransform]
REGEX = (\w+):'([^']+)'
FORMAT = $1::$2

props.conf

[mySourceType]
REPORT-myUniqueClassName = myTransform

This will create new fields using the value before the : and the actually value will be everything inside the single quoats.

Hope this helps ...

cheers, MuS

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...