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!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...