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!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...