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!

Modern way of developing distributed application using OTel

Recently, I had the opportunity to work on a complex microservice using Spring boot and Quarkus to develop a ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had 3 releases of new security content via the Enterprise Security ...

Archived Metrics Now Available for APAC and EMEA realms

We’re excited to announce the launch of Archived Metrics in Splunk Infrastructure Monitoring for our customers ...