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!

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

 Prepare to elevate your security operations with the powerful upgrade to Splunk Enterprise Security 8.x! This ...

Get Early Access to AI Playbook Authoring: Apply for the Alpha Private Preview ...

Passionate about security automation? Apply now to our AI Playbook Authoring Alpha private preview ...

Reduce and Transform Your Firewall Data with Splunk Data Management

Managing high-volume firewall data has always been a challenge. Noisy events and verbose traffic logs often ...