Splunk Search

How to calculate the Average Weighted as definition?

adamaso
New Member

Hello All

I have been looking on the forum for a solution on how to calculate the average weighted. I see several options, but not a clear one using the actual statistical approach: https://en.wikipedia.org/wiki/Weighted_arithmetic_mean.

Basically, I would like to try this:

Hits   AVG RT   Call
10       5        A
4        3        B
10       3        A
12       6        B
3        7        B
45       8        A

The idea is to follow the algorithm mentioned, calculating sum((hits* AVG RT)/sum(hits)) per call.

I tried on my own, but I am not an expert yet here on Splunk nomenclature.

Any help will be appreciated.

Thank you in advance!

Tags (2)
0 Karma

lguinn2
Legend

Try adding these 4 lines

...
| eval temp=hits * 'AVG RT'
| eventstats sum(hits) as totalhits sum(temp) as sumtemp
| eval wt_rt = sumtemp / totalhits
| fields - sumtemp totalhits
0 Karma

justinabrahms
New Member

I think this is close, but doesn't actually capture the "grouped per call" aspect of the original question.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...