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!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...