Splunk Search

compare the number of events from 2 subsearches in different indexes

imrago
Contributor

I would like to create an alert if the number on events is different in two subsearches.

subsearch1 = "index=index1 | dedup checksum | stats count"

subsearch2 = "index=index2 | dedup checksum | stats count"

unsuccessful attempts: 1) using subsearch

index=index1 | dedup checksum | stats count | search count > [search index=index2 | dedup checksum |stats count | search count]

2) using set diff

set diff [search index=index1 | dedup checksum] [search index=index2 | dedup checksum]
Tags (2)
1 Solution

gkanapathy
Splunk Employee
Splunk Employee
index=index1 OR index=index2 | dedup index,checksum | stats count by index | eval nevents="nevents" | xyseries index nevents count | where index1!=index2

Update:

Actually now that I think about it, this may be clearer and more generally useful:

index=index1 OR index=index2 | dedup index,checksum | stats count(eval(index=="index1")) as index1count, count(eval(index=="index2")) as index2count | where index1count!=index2count

View solution in original post

gkanapathy
Splunk Employee
Splunk Employee
index=index1 OR index=index2 | dedup index,checksum | stats count by index | eval nevents="nevents" | xyseries index nevents count | where index1!=index2

Update:

Actually now that I think about it, this may be clearer and more generally useful:

index=index1 OR index=index2 | dedup index,checksum | stats count(eval(index=="index1")) as index1count, count(eval(index=="index2")) as index2count | where index1count!=index2count
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!

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...