Splunk Search

Help in field extraction

badari
Engager

Hello,

Sorry for a newbie question, I have the following event thats generated


{
@timestamp: 2021-06-03T17:39:34.720+00:00
@version: 1
correlation: test12345
message:{"code":200,"data":{"status":"status1234"}}
}

 

What query should I use to extract status, my requirement is when I execute my query it should come in a tabular form as follows

status status1234

Thanks in advance.

 

Labels (3)
0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

@badari 

Can you please try this?

 

YOUR_SEARCH |spath message.data.status | rename message.data.* as * | table status | transpose

 

 

My Sample Search :

 

| makeresults | eval _raw="{\"@timestamp\": \"2021-06-03T17:39:34.720+00:00\",\"@version\": \"1\", \"correlation\": \"test12345\",\"message\":{\"code\":200,\"data\":{\"status\":\"status1234\"}}}"|spath message.data.status | rename message.data.* as * | table status | transpose

 

 

Screenshot 2021-06-04 at 11.40.08 AM.png

 


 Thanks
KV
▄︻̷̿┻̿═━一

If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

View solution in original post

isoutamo
SplunkTrust
SplunkTrust
You should use spath command
0 Karma

badari
Engager

Thanks, is it possible to give me the sample spath command that I can use? Tried searching but not getting a proper answer.

Tags (1)
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@badari 

Can you please try this?

 

YOUR_SEARCH |spath message.data.status | rename message.data.* as * | table status | transpose

 

 

My Sample Search :

 

| makeresults | eval _raw="{\"@timestamp\": \"2021-06-03T17:39:34.720+00:00\",\"@version\": \"1\", \"correlation\": \"test12345\",\"message\":{\"code\":200,\"data\":{\"status\":\"status1234\"}}}"|spath message.data.status | rename message.data.* as * | table status | transpose

 

 

Screenshot 2021-06-04 at 11.40.08 AM.png

 


 Thanks
KV
▄︻̷̿┻̿═━一

If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

Get Updates on the Splunk Community!

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 ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...