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)
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...