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

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Mastering Threat Intelligence in ES 8.5, Splunk AI Assistant v2, and More from Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...

Break the Build: Inside the KubeDoom Lounge at .conf26

    You step up to the machine. The pixelated corridors of a certain 1993 FPS load in front of you, EMP Pulse ...

Splunk Auto Ingestion Parallel Pipeline Scaling

Why this feature matters Many Splunk environments experience ingestion pressure long before the host is fully ...