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!

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

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...