Splunk Search

How to edit my map command search in order to pass a field to subsearch within subsearch?

snreichel
Engager

I've concluded that I absolutely need to use mapping, as I need to run the same (large) search query for each Iteration, the list of which must be found through another search. The Iteration must be referenced several times throughout this large search. However, this search also contains other necessary subsearches which use the Iteration as a variable. It works when hardcoded, but I can't pass the $Iteration$ thing into the inner subsearch.

<search to find Iterations>
| map 
    [ search index=caac sourcetype=UserStory _time<[| inputlookup caac_900_Sprint_Dates_lu where Iteration=$Iteration$ | return $epochSprintBegDate] ]

The actual search is much larger, but this is the portion of interest.
This will return the error: "Error in 'search' command: Unable to parse the search: Comparator '<' is missing a term on the right hand side."

0 Karma
1 Solution

micahkemp
Champion

I don't think you want to use time< to set your time period. Use earliest/latest instead. Check out this previous question for how this could be accomplished:

Using a time selector in a .dashboard - how can i make modifications to latest time in a query?

I'm sure there are more examples of this as well, this one just happened to be fresh on my mind.

View solution in original post

somesoni2
Revered Legend

The problem might be the dollar syntax. How about you give this a try. (renaming the output field to keyward query or search will return it's string value.

<search to find Iterations>
 | map 
     [ search index=caac sourcetype=UserStory _time<[| inputlookup caac_900_Sprint_Dates_lu | where Iteration=$Iteration$ | tabel epochSprintBegDate | rename epochSprintBegDate as query] ]
0 Karma

micahkemp
Champion

I don't think you want to use time< to set your time period. Use earliest/latest instead. Check out this previous question for how this could be accomplished:

Using a time selector in a .dashboard - how can i make modifications to latest time in a query?

I'm sure there are more examples of this as well, this one just happened to be fresh on my mind.

snreichel
Engager

_time was the issue
It works with a hardcoded Iteration but not with the mapped one, for some reason; but I did find an alternate method 🙂

0 Karma
Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...