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
Legend

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
Legend

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!

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