Splunk Search

Assigning arbitrary values to a variable dependent on subsearch

wardallen
Path Finder

I have a transaction defined where a trade goes through some stages in its lifecycle. Unfortunately, the markers for these stages aren't consistent in their form, eg.

"<$DealId> : The deal has hit stage BOOKED"

"<$DealId> : The deal is EXECUTED"

"<$DealId> : Received CONFIRMATION"

will be found at various times in the transaction.

I have come up with a query, but it keeps throwing errors : "Fields cannot be assigned a boolean result. Instead, try if([bool expr], [expr], [expr]). "

Here's the query

DealId="*" | transaction DealId |

eval confirmed=searchmatch("Received CONFIRMATION") |

eval executed=searchmatch("The deal is EXECUTED" AND "DownstreamSystemId" |

eval booked=searchmatch("Deal has hit stage EXECUTED") |

eval status=case(confirmed==true, "CONFIRMED", executed==true, "EXECUTED", booked==true, "BOOKED")

| table DealId, allocQty, price, value, transactTime, status

A completed transaction will have all of these stages, I'm trying to keep track of which stage a particular deal is up to.

It also feels horribly inefficient, is there a better way of writing this query?

Tags (1)
0 Karma

somesoni2
Revered Legend

Try this

DealId="*" | transaction DealId |
eval status=case(searchmatch("Received CONFIRMATION"), "CONFIRMED", searchmatch("\"The deal is EXECUTED\" AND \"DownstreamSystemId\""), "EXECUTED", searchmatch("Deal has hit stage EXECUTED"), "BOOKED")| table DealId, allocQty, price, value, transactTime, status
0 Karma
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!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...