Splunk Search

Working out the percentage from two fields

joe06031990
Communicator

Hi,

 

I am trying to calculate the percentage of two fields however the Perc filed is not being anything back:

Index=test sourcetype=Iis

|table response_time

|eval ResponseTime=response_time/1000

|eval isOver3s=if(ResponseTime>3,1,0)

|eval Perc=round((isOver3s/Event)*100,2)

|eventstats count as Event| stats Values(Event),sum(isOver3s)

|table Event, isOver3s, Perc

 

Any advice would be greatly appreciated.

 

thanks,

 

Joe 

Labels (5)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Eventstats to count the events needs to be before the eval that uses it.

Index=test sourcetype=Iis
|table response_time
|eval ResponseTime=response_time/1000
|eval isOver3s=if(ResponseTime>3,1,0)
|eventstats count as Event
|eval Perc=round((isOver3s/Event)*100,2)
|stats Values(Event),sum(isOver3s)
|table Event, isOver3s, Perc

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Eventstats to count the events needs to be before the eval that uses it.

Index=test sourcetype=Iis
|table response_time
|eval ResponseTime=response_time/1000
|eval isOver3s=if(ResponseTime>3,1,0)
|eventstats count as Event
|eval Perc=round((isOver3s/Event)*100,2)
|stats Values(Event),sum(isOver3s)
|table Event, isOver3s, Perc

joe06031990
Communicator

Hi,

 

I have tried this and works for the percentage however removes the events for isover3seconds.

 

Any thoughts?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
|stats Values(Event),sum(isOver3s),sum(Perc)
0 Karma
Get Updates on the Splunk Community!

Index This | When is October more than just the tenth month?

October 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What’s New & Next in Splunk SOAR

 Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us for an ...