Splunk Search

Help on this record select

yangadounb
Explorer

I have the record like this:  

 

_time  id status 

1        x     yes

1         x     no

2          x      yes

1          x      unknow 

 

I want to return the record based on status value: if status has yes ,then return the lasted row that has yes. if there is none yes value then I want the row with no,  if there is none yes or none no, return unknow row.

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| eval stat=case(status="yes",0,status="no",1,status="unknow",2)
| sort 0 stat - _time
| head 1

View solution in original post

yangadounb
Explorer

_time  id status 

1        x     yes

1         x     no

2          x      yes

1          x      unknow 

1        y     yes

1         y     no

2         y    yes

1          y      unknow 

2         z   yes

1          z    unknow 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| eval stat=case(status="yes",0,status="no",1,status="unknow",2)
| sort 0 stat - _time
| streamstats count by id
| where count = 1
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| eval stat=case(status="yes",0,status="no",1,status="unknow",2)
| sort 0 stat - _time
| head 1

yangadounb
Explorer

sorry not to make this clear ,  I have more records than that. 

0 Karma
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

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

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...