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!

October Community Champions: A Shoutout to Our Contributors!

As October comes to a close, we want to take a moment to celebrate the people who make the Splunk Community ...

Community Content Calendar, November Edition

Welcome to the November edition of our Community Spotlight! Each month, we dive into the Splunk Community to ...

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

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...