streamstats command overview - Splunk Documentation (2024)

The SPL2 streamstats command adds a cumulative statistical value to each search result as each result is processed. For example, you can calculate the running total for a particular field, or compare a value in a search result with a the cumulative value, such as a running average. The streamstats command includes options for resetting the aggregates.

Syntax

The required syntax is in bold.

streamstats
[<by-clause>]
[current=<bool>]
[<reset-clause>]
[window=<int>]
<aggregation> ...

How the SPL2 streamstats command works

Suppose that you have the following data:

hostactionbytes
xLOGON100
yAPP_START200
xFILE_DOWNLOAD400
xREBOOT50
yLOGON150
xLOGON100

You can use the SPL2 streamstats command to calculate and add various statistics to the search results.

Compute a moving average over a series of events

For each event, you can compute the average of the bytes field over the last 3 events, including the current event. Here's the search to use:

... | streamstats window=3 avg(bytes)


The output looks like this:

hostactionbytesavg(bytes)
xLOGON100100
yAPP_START200150
xFILE_DOWNLOAD400233.33
xREBOOT50216.66
yLOGON150200
xLOGON100100
  • For the first event, there are no previous events. The value for the bytes field is returned.
  • For the second event, the average is returned from the sum of first and second events.
  • For the remaining events, the average is returned from the sum of the current event and the two previous events.

Calculate a value until a trigger resets the calculation

Suppose you want to calculate a running total of the bytes for each host. However, when the system reboots you want the calculation for the total bytes to begin again. You can use the reset after argument to accomplish this. Here's the search to use:

...| streamstats sum(bytes) AS total_bytes BY host reset after action="REBOOT"

Because the value in the action field is a string literal, the value needs to be enclosed in double quotation marks.

The running total appears in the total_bytes field. The running total resets each time an event satisfies the action="REBOOT"criteria.

The results look like this:

hostactionbytestotal_bytes
xLOGON100100
yAPP_START200200
xFILE_DOWNLOAD400500
xREBOOT50550
yLOGON150150
xLOGON100100

The total_bytes field accumulates a sum of the bytes so far for each host. When the reset after clause action="REBOOT" occurs in the 4th event, that event shows the sum for the x host, including the bytes for the REBOOT action. The sum of the bytes is reset for both the y and x hosts in the next events.

Applying a count to each event

You can apply a running count to your search results, which is useful when combined with other commands.

...| streamstats count()

The output looks like this:

hostactionbytescount
x100LOGON1
yAPP_START2002
xFILE_DOWNLOAD4003
xREBOOT504
yLOGON1505
xLOGON1006

See also

streamstats command
streamstats command syntax details
streamstats command usage
streamstats command examples
Functions
Overview of SPL2 stats and chart functions
streamstats command overview - Splunk Documentation (2024)
Top Articles
Refineries should not pull stone by default
Spanish Letter Closings: formal, friendly, and informal - Wanderlust Spanish
Funny Roblox Id Codes 2023
Golden Abyss - Chapter 5 - Lunar_Angel
Www.paystubportal.com/7-11 Login
Shs Games 1V1 Lol
Evil Dead Rise Showtimes Near Massena Movieplex
Steamy Afternoon With Handsome Fernando
fltimes.com | Finger Lakes Times
Detroit Lions 50 50
18443168434
Newgate Honda
Zürich Stadion Letzigrund detailed interactive seating plan with seat & row numbers | Sitzplan Saalplan with Sitzplatz & Reihen Nummerierung
Grace Caroline Deepfake
978-0137606801
Nwi Arrests Lake County
Missed Connections Dayton Ohio
Justified Official Series Trailer
London Ups Store
Committees Of Correspondence | Encyclopedia.com
Pizza Hut In Dinuba
Jinx Chapter 24: Release Date, Spoilers & Where To Read - OtakuKart
How Much You Should Be Tipping For Beauty Services - American Beauty Institute
Sizewise Stat Login
VERHUURD: Barentszstraat 12 in 'S-Gravenhage 2518 XG: Woonhuis.
Jet Ski Rental Conneaut Lake Pa
Unforeseen Drama: The Tower of Terror’s Mysterious Closure at Walt Disney World
Ups Print Store Near Me
C&T Wok Menu - Morrisville, NC Restaurant
How Taraswrld Leaks Exposed the Dark Side of TikTok Fame
University Of Michigan Paging System
Dashboard Unt
Access a Shared Resource | Computing for Arts + Sciences
2023 Ford Bronco Raptor for sale - Dallas, TX - craigslist
Speechwire Login
Healthy Kaiserpermanente Org Sign On
Restored Republic
Progressbook Newark
Lawrence Ks Police Scanner
3473372961
Everstart Jump Starter Manual Pdf
Moxfield Deck Builder
Senior Houses For Sale Near Me
Flashscore.com Live Football Scores Livescore
Ksu Sturgis Library
Trivago Myrtle Beach Hotels
Thotsbook Com
Funkin' on the Heights
Caesars Rewards Loyalty Program Review [Previously Total Rewards]
Www Pig11 Net
Ty Glass Sentenced
Latest Posts
Article information

Author: Ouida Strosin DO

Last Updated:

Views: 6054

Rating: 4.6 / 5 (76 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Ouida Strosin DO

Birthday: 1995-04-27

Address: Suite 927 930 Kilback Radial, Candidaville, TN 87795

Phone: +8561498978366

Job: Legacy Manufacturing Specialist

Hobby: Singing, Mountain biking, Water sports, Water sports, Taxidermy, Polo, Pet

Introduction: My name is Ouida Strosin DO, I am a precious, combative, spotless, modern, spotless, beautiful, precious person who loves writing and wants to share my knowledge and understanding with you.