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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...