I'm trying to figure out if the following can be done with subsearch or requires a join.
I'm running a search that boils down to:
index=indexA sourcetype=outer [search index=indexB sourcetype=inner innerinput=abc | fields inneroutput1 inneroutput2 inneroutput3] | table _time host outeroutput1 outeroutput2 **inneroutput3**
My subsearch results provide the keys necessary for the main one, but I'd like one extra field to be passed to the final table without being used on the outer search.
Anything I'm missing or do I have to run a join just for that extra field?
let me understand: do you want to list events both from main search and subsearch or do you want to filter events from main search with the results of subsearch?
using the search you described, you reach the second solution and to add fields of the subsearch you have to use the join command.
So if inneroutput1 inneroutput2 inneroutput3 are three fields used to match the searches:
index=indexA sourcetype=outer | join inneroutput1 inneroutput2 inneroutput3 [search index=indexB sourcetype=inner innerinput=abc ] | table _time host outeroutput1 outeroutput2 inneroutput3
Join isn't a very performant command, so you could also use something like this:
(index=indexA sourcetype=outer) OR (index=indexB sourcetype=inner innerinput=abc) | stats dc(index) AS num_ind earliest(_time) AS _time values(host) AS host BY outeroutput1 outeroutput2 inneroutput3 | where num_ind>1 | fields - num_ind
return in the subsearch. ie .
Please be aware that by default, subsearches return a maximum of 10,000 results and have a maximum runtime of 60 seconds.