Splunk Search

How to assign the field value from a subsearch to outer search?

loveforsplunk
Explorer

Query I am using is :
index=anyvalue host=anyvalue keyword
[search index=anyvalue host=anyvalue source=y/y/y/y| fields + R1,R2|rename R1 as source |format "(" "(" "OR" ")" "OR" ")" ]
| table somefield, R2

R2 is a field extracted from the events in my sub search. I just want to display its value in Outer search.
My Outer search events does not contains this value R2 in the search results since my both the sources for both the inner and outer search are different.

R1 is another field extracted from the events in my sub search and is being used as a source for my outer search.

The question is I do not want a combined search of R1 and R2 in my outer search because that would give only events using R1 if I use the format command as used above. I just want to display R2 value in my outer search that's it.
Please help me.

Thanks in advance!

0 Karma
1 Solution

lguinn2
Legend

Try this instead:

index=anyvalue host=anyvalue keyword 
[search index=anyvalue host=anyvalue source=y/y/y/y 
    |eval resultfromsubsearch="x/x/x/"  + resultfromsubsearch 
    | return 2 source=resultfromsubsearch ] 
| table somefield

You may find the search job inspector useful to see how the subsearch is inserted into the outer search.

View solution in original post

0 Karma

lguinn2
Legend

Try this instead:

index=anyvalue host=anyvalue keyword 
[search index=anyvalue host=anyvalue source=y/y/y/y 
    |eval resultfromsubsearch="x/x/x/"  + resultfromsubsearch 
    | return 2 source=resultfromsubsearch ] 
| table somefield

You may find the search job inspector useful to see how the subsearch is inserted into the outer search.

0 Karma
Get Updates on the Splunk Community!

3 Ways to Make OpenTelemetry Even Better

My role as an Observability Specialist at Splunk provides me with the opportunity to work with customers of ...

What's New in Splunk Cloud Platform 9.2.2406?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.2.2406 with many ...

Enterprise Security Content Update (ESCU) | New Releases

In August, the Splunk Threat Research Team had 3 releases of new security content via the Enterprise Security ...