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
SplunkTrust
SplunkTrust

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
SplunkTrust
SplunkTrust

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!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...