Splunk Search

How to calculate the average of total column

ronak
Path Finder

I've following query...

What I'm interested in producing the output as,

OS Users Actions Actions_Per_User

IOS 20 200 10
Andriod 30 150 5
Total 50 350 7 (i.e. 250/5)

The following query,

  1. does not help with producing TOTAL raw
  2. Puts 7 (from total raw) as different column

How can I address this need..I tried using addcoltotals, but that does not help with the last column calculation for TOTAL row

pl help

index=mobile Action_Name=Page_View user_id!=NULL OS="Android" OR OS="IOS"|stats dc(user_id) as Users count as Launches by OS | eval unique_users= Users | eval actions_per_user= round((Launches/Users),2) | appendpipe [stats sum(Launches) as sum_launches sum(unique_users) as sum_unique_users] | eval avg_actions_per_user=round(sum_launches/sum_unique_users,0) | fields OS Users Launches actions_per_user avg_actions_per_user

Tags (1)
1 Solution

somesoni2
Revered Legend

Try this

index=mobile   Action_Name=Page_View  user_id!=NULL   OS="Android" OR OS="IOS"
|stats  dc(user_id) as Users  count as Actions  by OS   
| appendpipe [stats sum(Actions) as Actions  sum(Users) as Users | eval OS="Total"    ] 
| eval Actions_Per_Users=round(Actions/Users,0)

View solution in original post

somesoni2
Revered Legend

Try this

index=mobile   Action_Name=Page_View  user_id!=NULL   OS="Android" OR OS="IOS"
|stats  dc(user_id) as Users  count as Actions  by OS   
| appendpipe [stats sum(Actions) as Actions  sum(Users) as Users | eval OS="Total"    ] 
| eval Actions_Per_Users=round(Actions/Users,0)
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

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