Splunk Search

How can I get field extractions from a dictionary in a log?

daniel333
Builder

All,

I've done this before but I am rusty. My log looks like this

1/2/2019 12:34pm priority=info soemthing=12  mydictionary={"iq":"123", "lovescars":"True"}

Where mydictionary can as many as 30 elements in it. How do I get those into fields?

0 Karma

MuS
Legend

Hi daniel333,

try something like this in your transforms.conf:

 [GetFieldAndValueFromDict]
 SOURCE_KEY = mydictionary
 REGEX  = "([^"]+)":"([^"]+)"
 FORMAT = $1::$2

and this in your props.conf

 [mySourceType]
 REPORT-000-GetFieldAndValueFromDict = GetFieldAndValueFromDict

This will create a field name from capturing group one and the value from capturing group two from within the dict.
Put that on your search head and it will work at search time.

Hope this helps ...

cheers, MuS

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...