Splunk Search

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

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

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

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
State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!