Splunk Search

Searching transactions for field/values set in the same event

abelnation
Explorer

I have records of 3 forms:

{
"event": "START|MIDDLE|END",
"wasSuccessful": true/false,
"trans_id": <int>
}

How would I query for transactions where the "MIDDLE" event was not successful. It seems to me that once you've grouped into transactions, it becomes harder to make search terms conditional on certain events in the grouping.

E.g.

transaction trans_id | search event="MIDDLE" wasSuccessful=false

would return all transactions where the MIDDLE event occurred, and some other event in the transaction was not successful.

Any thoughts? Thanks!

1 Solution

wpreston
Motivator

How about using the mvlist flag on transaction and then use eval's mvindex function to find the value of wasSuccessful for the MIDDLE phase of your transaction.

transaction trans_id mvlist=wasSuccessful | eval middleFailed=if(mvindex(wasSuccessful,1)="true","No","Yes") | search event="MIDDLE" middleFailed="Yes"

This assumes that the failure would always occur during the second event of your transaction, which matches up with START|MIDDLE|END.

Another way to handle this would be to create a "middleFailed" field before you create your transactions, then search on that field afterwards, like so:

... | eval middleFailed=event."-".wasSuccessful | transaction trans_id | search event="MIDDLE" middleFailed="MIDDLE-true"

View solution in original post

wpreston
Motivator

How about using the mvlist flag on transaction and then use eval's mvindex function to find the value of wasSuccessful for the MIDDLE phase of your transaction.

transaction trans_id mvlist=wasSuccessful | eval middleFailed=if(mvindex(wasSuccessful,1)="true","No","Yes") | search event="MIDDLE" middleFailed="Yes"

This assumes that the failure would always occur during the second event of your transaction, which matches up with START|MIDDLE|END.

Another way to handle this would be to create a "middleFailed" field before you create your transactions, then search on that field afterwards, like so:

... | eval middleFailed=event."-".wasSuccessful | transaction trans_id | search event="MIDDLE" middleFailed="MIDDLE-true"

abelnation
Explorer

Awesome, this is super helpful. mvindex, mvlist, and mvfind all seem useful for this type of problem.

The key for me, is setting mvlist=t in my transaction command to ensure my multi-value fields are ordered in the grouped transaction.

Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...