Splunk Search

streamstats | reset_after condition not applied within the scope of each user (field)

ralam
Explorer

Hi Team,

What I'm trying to achieve: Find the consecutive failure events followed by a success event.

 

| makeresults | eval _raw="username,result
user1,fail
user2,success
user3,success
user1,fail
user1,fail
user1,success
user2,fail
user3,success
user2,fail
user1,fail"
| multikv forceheader=1
| streamstats count(eval(result="fail")) as fail_counter by username,result reset_after="("result==\"success\"")"
| table  username,result,fail_counter

 


Outcome: The counter (fail_counter) gets reset for a user (say user1) if the next event is a success event for a different user (say, user2).

usernameresultfail_counter 
user1fail1 
user2success0 
user3success0 
user1fail1<- counter reset for user1. It should be 2.
user1fail2It should be 3.
user1success0 
user2fail1 
user3success0 
user2fail1 
user1fail1 


Expected: The counter should not reset if the success event for user2 follows the failure event for user1.


I would appreciate any help on this. Not sure what I'm missing here.

Labels (1)
Tags (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

You could try sorting by username before the streamstats

View solution in original post

PickleRick
SplunkTrust
SplunkTrust

The docs on the streamstats command say that "all accumulated statistics" are reset on reset_* options. That would imply that the reset is global, not on a per "by-field(s)" basis.

It could call for docs feedback to make it more explicitly stated.

The practical solution to this you already got from @ITWhisperer 🙂

ITWhisperer
SplunkTrust
SplunkTrust

You could try sorting by username before the streamstats

Get Updates on the Splunk Community!

Splunk Search APIを使えば調査過程が残せます

   このゲストブログは、JCOM株式会社の情報セキュリティ本部・専任部長である渡辺慎太郎氏によって執筆されました。 Note: This article is published in both Japanese ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

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