Splunk Search

Average of the total count

krusovice
Path Finder

Hello all,

How can I get the average of the output as below?

Calculation is 40 + 20 + 50 / 3 = 36.6

REQUEST          ID          DURATION          AVERAGE
AAA              1122        40 seconds        36.6 seconds
BBB              3344        20 seconds
CCC              5566        50 seconds

Thanks.

Tags (2)
0 Karma
1 Solution

493669
Super Champion

Hi @krusovice,
try this:

...|rex field="DURATION" "(?<DURATION>\d+)"
|eventstats avg(DURATION) as average
|eval average=round(average,1)." seconds"

Try this run anywhere search:

|makeresults|eval REQUEST="AAA", DURATION="40 seconds"
|append[|makeresults|eval REQUEST="BBB", DURATION="20 seconds"]
|append[|makeresults|eval REQUEST="CCC", DURATION="50 seconds"]
|rex field="DURATION" "(?<DURATION>\d+)"
|eventstats avg(DURATION) as average
|eval average=round(average,1)." seconds"

View solution in original post

0 Karma

deepashri_123
Motivator

Hey krusovoice,

You can try this run anywhere query:

| makeresults | eval Request="AAA BBB CCC" | makemv Request| mvexpand Request | appendcols [| makeresults | eval ID="1122 3344 5566" | makemv ID| mvexpand ID ] |  appendcols [| makeresults | eval Duration="40seconds 50seconds 20seconds" | makemv Duration| mvexpand Duration ] |rex field=Duration "(?P<Dur>\d+)"| eventstats avg(Dur) AS avgDur

OR you can add this to your query:
|rex field=Duration "(?P\d+)"| eventstats avg(Dur) AS avgDur

Let me know if this helps!!

0 Karma

krusovice
Path Finder

Hi deepashri_123,

eventstats just make the trick! Thank you as always.

0 Karma

deepashri_123
Motivator

@krusovice,
Please Upvote the answer if that helped!!
Thanks!!

0 Karma

493669
Super Champion

Hi @krusovice,
try this:

...|rex field="DURATION" "(?<DURATION>\d+)"
|eventstats avg(DURATION) as average
|eval average=round(average,1)." seconds"

Try this run anywhere search:

|makeresults|eval REQUEST="AAA", DURATION="40 seconds"
|append[|makeresults|eval REQUEST="BBB", DURATION="20 seconds"]
|append[|makeresults|eval REQUEST="CCC", DURATION="50 seconds"]
|rex field="DURATION" "(?<DURATION>\d+)"
|eventstats avg(DURATION) as average
|eval average=round(average,1)." seconds"
0 Karma

krusovice
Path Finder

Thank you @493669 for the great helps! It's work well in my dashboard.

0 Karma
Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...