Splunk Search

Compare the stats output value

prettysunshinez
Explorer

State Date Desc Count
bc 11102021 vm 234569
bc 12102021 vm 456328
bc 11102021 vm 234569
bc 12102021 vm 4532178
cd 11102021 vm 234000
cd 12102021 vm 234000
cd 11102021 vm 234000
cd 12102021 vm 568902


From the stats output (such as above),I would like to first group them as per state, then compare the count[0] with that of count[1] and then count[2] with count [3] and then count [3] with count [0],if any one matches then should be displayed as result.

In the above case for state=cd,index[0] and index[1] are same,so the expect result is

State Date Desc Count

cd 11102021 vm 234000
cd 12102021 vm 234000

Please assist

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| makeresults
| eval _raw="State,Date,Desc,Count
bc,11102021,vm,234569
bc,12102021,vm,456328
bc,11102021,vm,234569
bc,12102021,vm,4532178
cd,11102021,vm,234000
cd,12102021,vm,234000
cd,11102021,vm,234000
cd,12102021,vm,568902"
| multikv forceheader=1
| table State,Date,Desc,Count
| streamstats count as row by State
| eval row=if(row=4,mvappend(row,"0"),row)
| mvexpand row
| sort 0 State -row
| streamstats values(Count) as next current=f window=1 by State
| where row>0 AND Count=next
| sort 0 State row
0 Karma
Get Updates on the Splunk Community!

CX Day is Coming!

Customer Experience (CX) Day is on October 7th!! We're so excited to bring back another day full of wonderful ...

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...