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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...