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!

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

Splunk Decoded: Business Transactions vs Business IQ

It’s the morning of Black Friday, and your e-commerce site is handling 10x normal traffic. Orders are flowing, ...

Fastest way to demo Observability

I’ve been having a lot of fun learning about Kubernetes and Observability. I set myself an interesting ...