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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...