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!

Splunk Observability Cloud's AI Assistant in Action Series: Auditing Compliance and ...

This is the third post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

What You Read The Most: Splunk Lantern’s Most Popular Articles!

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...