Splunk Search

How extract specific value ?

Jean-Sébastien
Observer

Hello, 

I have big and complete log and want to extract specific value. 

Small part of log: "state":{"running":{"startedAt":"2024-12-19T13:58:14Z"}}}],

I would like to extract running in this case, value can be other . 

Could you please help me ? 

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

This looks like it might be JSON. Have you looked at the json functions?

kiran_panchavat
Champion

@Jean-Sébastien 


You can use rex command. The rex command matches the value of the specified field against the unanchored regular expression and extracts the named groups into fields of the corresponding names.

https://docs.splunk.com/Documentation/Splunk/9.4.0/SearchReference/Rex 

Did this help? If yes, please consider giving kudos, marking it as the solution, or commenting for clarification — your feedback keeps the community going!
0 Karma

kiran_panchavat
Champion

Hello @Jean-Sébastien 

You can use regex. This will create a new field called output that contains the values running, drinking, and walking. Let me know if you need more assistance!

kiran_panchavat_0-1735811981423.png

 

 

Did this help? If yes, please consider giving kudos, marking it as the solution, or commenting for clarification — your feedback keeps the community going!

yuanliu
SplunkTrust
SplunkTrust

It is best not to use rex to extract information from structured data.  As @ITWhisperer says, the OP should post complete sample logs instead of a fragment of JSON.  If the raw event is itself compliant JSON, there should be no need to extract using search commands because Splunk automatically does this at search time.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...