Splunk Search

How to pass the date and time result from an inner search to the outer search?

Karan_Jindal
New Member

Hi,

My inner search returns the date and time (for eg 06-22-2015-23). I want to use this time in my outer search as earliest time = "06-22-2015-23" and latest should be one hour after that(06-23-2015-00) i.e one hour post the earliest time.

For eg.

"outer search" [search ... | eval MyLatestTime=_time | fields + MyLatestTime | rename MyLatestTime as earliest] latest= earliest+1

Thanks in advance

Tags (2)
0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

This should do:

"outer search" [search ... | eval earliest = _time | eval latest = relative_time(_time, "+h") | fields earliest latest | format "" "" "" "" "" ""]

View solution in original post

martin_mueller
SplunkTrust
SplunkTrust

This should do:

"outer search" [search ... | eval earliest = _time | eval latest = relative_time(_time, "+h") | fields earliest latest | format "" "" "" "" "" ""]

martin_mueller
SplunkTrust
SplunkTrust

Yeah, to the very end.

info_min_time is a field added by addinfo, containing the minimum end of the time range set by earliest.
http://docs.splunk.com/Documentation/Splunk/6.2.3/SearchReference/addinfo

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

In order to display the earliest time used in a search you can append this to the end:

... | addinfo | eval fieldname = strftime(info_min_time, "%m-%d-%Y-%H") | fields - info_*
0 Karma

Karan_Jindal
New Member

I'm still not clear.
how is info_min_time related to earliest time ?

do you mean to append this information at like :

outer search" [search ... | eval earliest = time | eval latest = relative_time(_time, "+h") | fields earliest latest] | addinfo | eval fieldname = strftime(info_min_time, "%m-%d-%Y-%H") | fields - info*

0 Karma

Karan_Jindal
New Member

Thanks Martin.
I have one more requirement. I want to show the result of inner query i.e (06-22-2015-23) in the results of outer search.

For eg. if my outer search returns A,B,c I want something like A,B,C,06-22-2015-23.

Thanks

0 Karma
Get Updates on the Splunk Community!

Upcoming Webinar: Unmasking Insider Threats with Slunk Enterprise Security’s UEBA

Join us on Wed, Dec 10. at 10AM PST / 1PM EST for a live webinar and demo with Splunk experts! Discover how ...

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...