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!

Automatic Discovery Part 1: What is Automatic Discovery in Splunk Observability Cloud ...

If you’ve ever deployed a new database cluster, spun up a caching layer, or added a load balancer, you know it ...

Real-Time Fraud Detection: How Splunk Dashboards Protect Financial Institutions

Financial fraud isn't slowing down. If anything, it's getting more sophisticated. Account takeovers, credit ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...