Splunk Search

What kind of scenario we use eventstats vs stats?

AL3Z
Builder
Hi, Could you pls let me know in what scenario would we use eventstats vs stats?
Labels (1)
0 Karma

kiran_panchavat
Champion

@AL3Z 

Stats:-

Calculates aggregate statistics over the entire dataset or subsets of the dataset.

kiran_panchavat_0-1736185163186.png

 

Eventstats:-

Calculates summary statistics for all existing fields in the search results and adds these statistics as new fields to each event.

kiran_panchavat_1-1736185215666.png

I hope this helps, if any reply helps you, you could add your upvote/karma points to that reply, thanks.

Did this help? If yes, please consider giving kudos, marking it as the solution, or commenting for clarification — your feedback keeps the community going!
0 Karma

richgalloway
SplunkTrust
SplunkTrust

stats is a transforming command whereas eventstats is not.  IOW, the output of stats contains only the fields explicitly given in the command, but the output of eventstats contains all of the existing event fields *plus* those calculated by the command.

Use eventstats when you need to do a calculation across all events, while preserving the events themselves.  For example, to list the events where a field value exceeds the average.

 

...
| eventstats avg(x) as AvgX
| where x > AvgX
...

 

 

---
If this reply helps you, Karma would be appreciated.
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Eventstats can add new fields to existing events, (hence the name), whereas, using stats replaces existing events with stats events. So, scenarios where you want to keep the events, you might use eventstats, where you want to replace the events with the results of stats functions, you would use stats.

0 Karma
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!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...