Splunk Search

Is there any way to get the top 10 hosts with event count spike compared to Yesterday's event count in splunk from a lookup which contains hosts?

pavanae
Builder

I have lookup file which contains a list of hosts around 500 as follows

host
A
B
C
d

Now, how to write a query to identify the top 10 hosts with event count spike compared to yesterday's event count ? Probably like below or any better way of presenting this would be helpfull.

host Yesterday Today
D 2.2 GB 8 GB
H 1.1 GB 3 GB
Y 0.5 GB 1.4 GB

0 Karma
1 Solution

DalJeanis
SplunkTrust
SplunkTrust

You can do this for count or for sum(bytes) or for whatever you want, the code will work pretty much the same.

 your search that gets all yesterdays and today's events with field host
 | bin _time span=1d
 | stats count by host _time
 | eventstats min(_time) as yesterday max(_time) as today
 | eval flag=case(yesterday=today,"you didn't pick two days")
 | eval change=if(_time=yesterday,-count,count)
 | stats sum(eval(case(_time=yesterday,count))) as Yesterday, sum(eval(case(_time=today,count))) as Today, sum(eval(if(_time=yesterday,-count,count))) as Change by host
 | sort 10 - Change

View solution in original post

0 Karma

DalJeanis
SplunkTrust
SplunkTrust

You can do this for count or for sum(bytes) or for whatever you want, the code will work pretty much the same.

 your search that gets all yesterdays and today's events with field host
 | bin _time span=1d
 | stats count by host _time
 | eventstats min(_time) as yesterday max(_time) as today
 | eval flag=case(yesterday=today,"you didn't pick two days")
 | eval change=if(_time=yesterday,-count,count)
 | stats sum(eval(case(_time=yesterday,count))) as Yesterday, sum(eval(case(_time=today,count))) as Today, sum(eval(if(_time=yesterday,-count,count))) as Change by host
 | sort 10 - Change
0 Karma

micahkemp
Champion

Can you add more context to your lookup file and/or indexed data that you are trying to create a search for?

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 ...