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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...