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!

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco + Splunk! We’ve ...