Splunk Search

Searches separated by Colon

ekucevic
Loves-to-Learn Everything

I source database that displays all of the info i need that is separated by colon. Example "ilruPartNumber":"12345"., "lruSoftwareVersion":"7.10.0.74". All of the info i need is separated by an " : "


What i want is to separate the search to list the Name then Number. Example ilruPartNumber = 12345.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex "\"(?<key>[^\"]+)\":\"(?<value>[^\"]+)\""
| eval {key}=value
0 Karma

ekucevic
Loves-to-Learn Everything
Spoiler
I am a beginner here so alittle bit of a walk through could be necessary. 
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

The rex command (without a field argument) will operate on the _raw field of each event. The regex used extracts the part before the colon into a field called key and the part afterwards into a field called value. The eval command creates a field using the name in the key field and with the value from the value field. This is the basis for extracting the field. If you want a more precise version of the command, you should share some anonymised events, that you have already retrieved with your search, so the command can be tailored to your specific case.

0 Karma

ekucevic
Loves-to-Learn Everything

Hi, Thanks for your reply, I think my issue is due to quotes within quotes? No sure. Below is a sample of my search. Basically everything in red is a sample what i am searching for. 

 

[{"lruName":"Modem","lruType":"MBR","lruMacAddress":"00:A0:BC:72:6F:44","lruModelNumber":"MBR-5500","lruSerialNumber":"C80016506037","lruPartNumber":"1244523","lruSoftwareVersion":"M3-1.3.5.2.89_2021.06.18","lruConfigVersion":"7.10.0.38"

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

This looks like JSON, perhaps you should investigate spath as a way to extract the fields

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...