Splunk Search

How to generate a search that will compare Log_Level events to the total number of events?

mercur
New Member

Hi

I want to do a search of something i would think would be very simple but i cant get it to work.

I want to compare the Log_Level Events that i have to the total events for that day?

So for example WARN/TotalEvents in 24 Hours.

Hope someone can help

0 Karma
1 Solution

somesoni2
Revered Legend

Try something like this.

your base search Log_Level=* | stats count as TotalEvents count(eval(Log_Level="WARN")) as WARN 

OR

your base search Log_Level=* | eval WARN=if(Log_Level="WARN",1,0) |  stats count as TotalEvents sum(WARN) as WARN 

View solution in original post

0 Karma

somesoni2
Revered Legend

Try something like this.

your base search Log_Level=* | stats count as TotalEvents count(eval(Log_Level="WARN")) as WARN 

OR

your base search Log_Level=* | eval WARN=if(Log_Level="WARN",1,0) |  stats count as TotalEvents sum(WARN) as WARN 
0 Karma

mercur
New Member

That worked flawlessly i think i made it to complicated.

To get the Percentage i added eval percentage=(WARN/TotalEvents) | table percentage is this the right way to do it ?

0 Karma

somesoni2
Revered Legend

Yes.. I would use something like this for more human readable format of percentage

...| eval percentage=round(WARN*100/TotalEvents,2))
0 Karma
Get Updates on the Splunk Community!

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

New Release | Splunk Cloud Platform 10.1.2507

Hello Splunk Community!We are thrilled to announce the General Availability of Splunk Cloud Platform 10.1.2507 ...

🌟 From Audit Chaos to Clarity: Welcoming Audit Trail v2

🗣 You Spoke, We Listened  Audit Trail v2 wasn’t written in isolation—it was shaped by your voices.  In ...