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!

Event Series: Telemetry Pipeline Management

Balancing Scale and Spend: Gaining Control Over High-Volume Metrics in Splunk Observability Cloud As ...

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...

Deep insights, no barriers: Splunk Observability Cloud Free Edition

As software delivery cycles continue to accelerate, observability shouldn’t be a luxury — it should be a ...