Splunk Search

How to pass a value extracted from a main search to a sub search from different source?

vivek991985
New Member

Example:

source="FILE1.log" search_input | rex ".*]*Rpc id :(?[0-9][0-9][0-9][0-9][0-9][0-9])" | append [search source ="FILE2.log" rpc_id]
0 Karma
1 Solution

Sukisen1981
Champion

Hi @vivek991985
You can't pass a value from a main search to a sub search, it works the other way round.
That being said and from what I can understand try something like this -

source ="FILE2.log"  | eval id=[search  source="FILE1.log" search_input | rex ".*]*Rpc id :(?[0-9][0-9][0-9][0-9][0-9][0-9])" |return $rpc_id]

Basically, the eval gets executed first and whatever rex you are performing (assuming the rex works) gets assigned o the field id, you can then pipe on and do what you need with file2log source

View solution in original post

0 Karma

Sukisen1981
Champion

Hi @vivek991985
You can't pass a value from a main search to a sub search, it works the other way round.
That being said and from what I can understand try something like this -

source ="FILE2.log"  | eval id=[search  source="FILE1.log" search_input | rex ".*]*Rpc id :(?[0-9][0-9][0-9][0-9][0-9][0-9])" |return $rpc_id]

Basically, the eval gets executed first and whatever rex you are performing (assuming the rex works) gets assigned o the field id, you can then pipe on and do what you need with file2log source

0 Karma

vivek991985
New Member

Thank you @Sukisen1981

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...