Splunk Search

How do I extract Key Value pairs from Ruby on Rails logs?

Simeon
Splunk Employee
Splunk Employee

I am trying to extract field and key/value parameters from a ruby on rails log file. What ways can I do this? My events have Parameters in the following format:

Processing blah blah blah
  Parameters:  {"item1"=>"food", "item2"=>"drink", "item3"=>"water"}

Simeon
Splunk Employee
Splunk Employee

You can do this via configuration files or search-time "kv" (aka extract command). Specifically, for your situation you want to delimit based on the "=>" and ", ". You can use the extract command as follows:

... | extract pairdelim=", }{", kvdelim="=>", auto=f 

This will turn off auto extraction, break the key value pairs based on the =>, and break the pairs based on the "," whitespace, or either curly bracket. So your extracted fields would be:

item1=food
item2=drink
item3=water
Get Updates on the Splunk Community!

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 at Splunk .conf24 ...

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

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...