Splunk Search

Calculation using the number of events returned to determine average

dwong2
New Member

I have data similiar to this:

Account Count TotalSessions
abc 4 12
xyz 2 12
zzz 6 12

..search | stats count by Account | eventstats sum(count) as TotalSessions

How do I get the calculation for TotalSessions/ # of Accounts? i.e. 12 divided by 3 in this example.

Tags (1)
0 Karma
1 Solution

somesoni2
Revered Legend

Like this

..search | stats count by Account | eventstats sum(count) as TotalSessions dc(Account) as TotalAccounts
| eval AvgSessionPerAccount=TotalSessions/TotalAccounts

View solution in original post

dwong2
New Member

Thanks for the quick solution. I'm now getting multiple instances for the calculation of AvgSessionPerAccount. How do I only show one result since all are the same?

0 Karma

somesoni2
Revered Legend

Like this

..search | stats count by Account | eventstats sum(count) as TotalSessions dc(Account) as TotalAccounts
| eval AvgSessionPerAccount=TotalSessions/TotalAccounts

dwong2
New Member

Thanks for the quick solution. I'm now getting multiple instances for the calculation of AvgSessionPerAccount. How do I only show one result since all are the same?

0 Karma
Get Updates on the Splunk Community!

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...

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

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...