Splunk Search

How to calcualte the count diff between 2 searches?

jerrytao
New Member

index=A | stats count as count1
index=A | dedup field1 field2 | stats count as count2

This 2 searched have same index A, then I want to calculate (count1-count2).

Anyone can help on this? Thanks in advance!

Tags (2)
0 Karma
1 Solution

vnravikumar
Champion

Hi

Try this

index=A | stats count as count1
| appendcols 
    [| search index=A | dedup field1 field2 | stats count as count2] |eval diff = count1-count2

View solution in original post

0 Karma

vnravikumar
Champion

Hi

Try this

index=A | stats count as count1
| appendcols 
    [| search index=A | dedup field1 field2 | stats count as count2] |eval diff = count1-count2
0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...