Splunk Search

Can you help me with a query using the streamstats command?

zacksoft
Contributor

Here is how events are,

2018-12-20T13:38:07.938-0500: 28658.929: [**Dull BC** (Allocation Failure) 
2018-12-20T13:38:12.764-0500: 28663.756: [SoftReference, 410050 refs, 0.1673385 secs
2018-12-20T13:38:12.932-0500: 28663.923: [WeakReference, 117939 refs, 0.0132928 secs]
2018-12-20T13:38:12.945-0500: 28663.936: [FinalReference, 476 refs, 0.0002134 secs]
2018-12-20T13:38:12.945-0500: 28663.937: [PhantomReference, 658 refs, 789 refs, 0.0002301 secs]
2018-12-20T13:38:12.945-0500: 28663.937: [JNI Weak Reference, 0.0005271 secs]
 17G->7032M(18G), **16.4882875** secs]

I am hoping streamstats would be able to help me with the following requirement,

If splunk search encounters the keyword 'Dull BC', then the control should jump to the next 5th event/sentence/line and fetch the value '16.2882857' for me.

0 Karma
1 Solution

whrg
Motivator

Hello @zacksoft,

You could use the streamstats command like this:

your base search
| streamstats count reset_after="("like(_raw,\"%Dull BC%\")")"
| search count=5

However, you will notice a minor glitch with this command: If the the first couple of lines do not contain "Dull BC" then the fifth line will have a count of 5 regardless.

Perhaps you could also use the transaction command:

your base search | sort -_time
| transaction startswith="**Dull BC**" endswith="JNI Weak Reference" maxevents=6

View solution in original post

whrg
Motivator

Hello @zacksoft,

You could use the streamstats command like this:

your base search
| streamstats count reset_after="("like(_raw,\"%Dull BC%\")")"
| search count=5

However, you will notice a minor glitch with this command: If the the first couple of lines do not contain "Dull BC" then the fifth line will have a count of 5 regardless.

Perhaps you could also use the transaction command:

your base search | sort -_time
| transaction startswith="**Dull BC**" endswith="JNI Weak Reference" maxevents=6

zacksoft
Contributor

Thank you.
The transaction command does the job, but I see anomaly.
sometimes maxevents = 6 shows the lines but mazevents = 9 doesn't.
It's strange..

0 Karma
Get Updates on the Splunk Community!

Get Inspired! We’ve Got Validation that Your Hard Work is Paying Off

We love our Splunk Community and want you to feel inspired by all your hard work! Eric Fusilero, our VP of ...

What's New in Splunk Enterprise 9.4: Features to Power Your Digital Resilience

Hey Splunky People! We are excited to share the latest updates in Splunk Enterprise 9.4. In this release we ...

Take Your Breath Away with Splunk Risk-Based Alerting (RBA)

WATCH NOW!The Splunk Guide to Risk-Based Alerting is here to empower your SOC like never before. Join Haylee ...