Splunk Search

Using subsearch results to loop through another search?

jeck11
Path Finder

I have been reviewing the countless other postings on subsearches but I can't pull them all together to figure out our issue. 

This first search builds a list of carts that we need to find the contents of:

index="name" "Authorization was not successful!" AND /placeorder
| rex field=_raw "/carts/(?<cart>.+)/placeorder" | dedup cart | table cart



This is where I run into issues. I need to take the table created in that search and find all of the items contained in them. 

Here is the search for a single cart from that list:

index="name" "3322830131/processCheckout" AND "\"paymentProvider\":\"PayPal\""



My thought is that I need to cycle through the table from the subsearch, replacing the number in this search, then finally building a visualization that shows the contents of each cart using the most recent event in the second search. 

Am I way off? This seems pretty easy but I can't figure it out. TYIA

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

index="name" "\"paymentProvider\":\"PayPal\"" [ search index="name" "Authorization was not successful!" AND /placeorder
| rex field=_raw "/carts/(?<cart>.+)/placeorder" | dedup cart | eval search=cart."/processCheckout" | fields search | format ]

The field "search" is given special treatment by format such that just the values are kept, not the field name i.e. "value" rather than 'search="value"'

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...