Splunk Search

how can I calculate the average of field1,field2,field3 for users and display the average of each user?

pavanae
Builder

I have a splunk result as below

user field1 field2 field3
A 5 8 3
B 2 3 5

Now how can I calculate the average of field1,field2,field3 for users and display the average of each user?

0 Karma
1 Solution

woodcock
Esteemed Legend

Like this:

Your Base Search Here | stats avg(eval(field1+field2+field3)) AS all_avg BY user

View solution in original post

0 Karma

woodcock
Esteemed Legend

Like this:

Your Base Search Here | stats avg(eval(field1+field2+field3)) AS all_avg BY user
0 Karma

hunters_splunk
Splunk Employee
Splunk Employee

Hi pavanae,

You can use the eval function to create a new user-average field in your search command.

... | eval user-avg=(field1+field2+field3)/3

Hope this helps.
Thanks
Hunter

0 Karma

gokadroid
Motivator

Try this:

your query to return user, field1, field2, field3
| stats avg(field1) as avg1, avg(field2) as avg2, avg(field3) as avg3 by user
0 Karma
Get Updates on the Splunk Community!

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

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

[Puzzles] Solve, Learn, Repeat: Reprocessing XML into Fixed-Length Events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...