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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...