Splunk Search

How to get average value of fields?

sekhar463
Path Finder

hi all,

i have some events with a field called RUNTIME for each job.

how can i get the average value of RUNTIME for each of the job and result will be on new field

 

2022-12-14 08:10:00.995, JOID="105459", JOB_NAME="PNC-UIT-INVOBT-STANDARD-TEST-125", JOB_GROUP="UIT", TIMEZONE="Central", RUN_NUM="403676470", NTRY="1", RUN_MACHINE="usappasyswp125", STATUS_CODE="4", STATUS="SUCCESS", STATUS_TIME="2022/12/14 05:33:49", LAST_START="2022/12/14 05:33:20", LAST_END="2022/12/14 05:33:48", DATE_CONDITIONS="0", RUNTIME="28", EXIT_CODE="0"

Labels (2)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

I assume "results will be new field" means that you want the average along with raw events.  In this case, eventstats is your friend.

| eventstats avg(RUNTIME) AS RUNTIME_avg BY JOID

 

Tags (1)
0 Karma

gcusello
Esteemed Legend

Hi @sekhar463 ,

pease try something like this:

<your_search>
| stats avg(RUNTIME) AS RUNTIME_avg BY JOID

Ciao.

Giuseppe

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| stats avg(RUNTIME) as average_runtime
0 Karma
Get Updates on the Splunk Community!

Build Scalable Security While Moving to Cloud - Guide From Clayton Homes

 Clayton Homes faced the increased challenge of strengthening their security posture as they went through ...

Mission Control | Explore the latest release of Splunk Mission Control (2.3)

We’re happy to announce the release of Mission Control 2.3 which includes several new and exciting features ...

Cloud Platform | Migrating your Splunk Cloud deployment to Python 3.7

Python 2.7, the last release of Python 2, reached End of Life back on January 1, 2020. As part of our larger ...