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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...