Splunk stats vs eventstats vs streamstats: Examples, Output Tables & Exam Guide

By Splunky · Updated November 20, 2026

One-sentence rule: Use stats when you only want a summary table; use eventstats when you need to compare each individual event against a group total or average; use streamstats when you need a running total, counter, or sliding window in event order.

At-a-glance comparison

Featurestatseventstatsstreamstats
Command typeTransforming (collapses events)Dataset processing (keeps all events)Streaming / stateful (keeps all events)
Output row count1 row per unique BY groupSame number of rows as input eventsSame number of rows as input events
Raw fields preserved?No (only BY fields + aggregates remain)Yes (all original fields stay intact)Yes (all original fields stay intact)
Scope of mathEntire search result setEntire search result setEvents seen so far (or last N via window=N)
Classic use caseDashboards, top talkers, KPI tablesOutlier detection (bytes > 3 * avg_bytes), % of totalBrute-force login counters, cumulative bandwidth, session numbering

Seeing all three on the exact same 4 events

Suppose our base search (sorted chronologically with | sort 0 _time) returns these 4 web events:

_timehosturims
10:00:01web01/login100
10:00:02web01/checkout500
10:00:03web02/login200
10:00:04web01/home300

1. stats: Collapse into a summary table

index=web | sort 0 _time
| stats count, avg(ms) AS avg_ms BY host

stats discards _time and uri and outputs 2 summary rows (one per host):

hostcountavg_ms
web013300
web021200

2. eventstats: Stamp the overall group average onto every event

index=web | sort 0 _time
| eventstats avg(ms) AS host_avg_ms BY host
| eval is_slow = if(ms > host_avg_ms, "YES", "no")

Every web01 row receives the final 3-event average (300), making it trivial to spot that /checkout (500 ms) was slower than web01's own baseline:

_timehosturimshost_avg_msis_slow
10:00:01web01/login100300no
10:00:02web01/checkout500300YES
10:00:03web02/login200200no
10:00:04web01/home300300no

3. streamstats: Calculate a running average / counter as each event arrives

index=web | sort 0 _time
| streamstats count AS req_num, avg(ms) AS running_avg_ms BY host

Notice how web01's running_avg_ms updates step-by-step (100, then (100+500)/2 = 300, then (100+500+300)/3 = 300):

_timehosturimsreq_numrunning_avg_ms
10:00:01web01/login1001100
10:00:02web01/checkout5002300
10:00:03web02/login2001200
10:00:04web01/home3003300

Practice these commands live → SPLK-1001 SPL Lab: stats · SPLK-1002 Lesson: eventstats · SPLK-1002 Lesson: streamstats

High-value streamstats options tested on SPLK-1002 & SPLK-1004

  • window=N (Sliding Window): Compute statistics across only the most recent N events rather than all prior events (e.g., | streamstats window=5 avg(cpu) AS rolling_cpu).
  • current=false (Compare to Prior Events Only): Exclude the current event from the calculation—ideal for comparing an event to the previous event's timestamp or IP address:
    index=auth action=success
    | sort 0 user _time
    | streamstats current=false last(src_ip) AS prev_ip, last(_time) AS prev_time BY user
    | where isnotnull(prev_ip) AND src_ip != prev_ip
  • reset_on_change=true (Streak Counter): Reset the running calculation whenever the BY field changes—perfect for counting consecutive failed logins before a successful login:
    index=auth user=jdoe
    | sort 0 _time
    | streamstats reset_on_change=true count AS consecutive_attempts BY action

Common exam gotchas

  1. Event ordering trap: Splunk returns events newest-first by default. Running streamstats without | reverse or | sort 0 _time computes values backward in time!
  2. Memory & result limits: eventstats and streamstats process events on the search head rather than reducing them on indexers. Always filter with index=, sourcetype=, and | fields first, and prefer tstats or stats when you do not need individual raw events preserved.
  3. Calculating percentage of total without subsearches: Pair stats + eventstats instead of slow appendpipe or subsearches:
    index=web
    | stats count BY status
    | eventstats sum(count) AS total
    | eval pct = round((count / total) * 100, 2)

Next steps

Frequently asked questions

What is the main difference between stats, eventstats, and streamstats in Splunk?

stats is a transforming command that collapses raw events into a summary table (one row per group). eventstats calculates the exact same summary across the whole dataset, but appends the result as a new field onto every original event without removing raw fields. streamstats calculates a running (cumulative or sliding-window) statistic in the exact order events flow through the pipeline.

In what chronological order does streamstats process events?

By default, Splunk returns events in reverse chronological order (newest first). If you want streamstats to calculate a true forward-in-time running total or sequence number, pipe through | reverse or | sort 0 _time before running | streamstats.

Which command is fastest: stats, eventstats, or streamstats?

stats is the fastest because indexers perform map-reduce pre-aggregation before sending small summary rows to the search head. eventstats and streamstats must retain individual events in memory/disk on the search head, so always filter events as early as possible before using them.

Which Splunk certification exams test stats vs eventstats vs streamstats?

stats is heavily tested on SPLK-1001 (Core Certified User). Comparing stats, eventstats, and streamstats (including window=, current=, and reset_on_change) is a signature exam topic on SPLK-1002 (Core Certified Power User), SPLK-1004 (Advanced Power User), and SPLK-5001 (CDA).