Splunk Enterprise

returning _time from subsearch to main search

rmurthy
Engager

Hi,
I want to run a subsearch, pass the host and _time to the main search. The main search will look for some other events for the host from earliest=_time (returned from subsearch) and latest=_time + x hrs.
Can you tell me how can I achieve this?

Thanks.

Tags (1)

dwaddle
SplunkTrust
SplunkTrust

You can directly return earliest and latest from the subsearch, which should do what you want.

sourcetype=foo bar baz [ search sourcetype=blah 
|eval earliest=field1 
| eval latest=field1+3600 
| fields earliest, latest ]

sowings
Splunk Employee
Splunk Employee

Have your subsearch return terms of earliest and latest. So this might look like

[ search <subsearch> | rename \_time AS earliest | eval latest=earliest + (3600 * x) | fields earliest, latest ]
<main_search>

Where x is your number of hours. The _time field is an epoch time, hence doing math in seconds.

Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...