Splunk Search

variable time search

kvmanjunath
New Member

Hi, I am trying to search a query where I need a _time value from sub search to the main search and in main search earliest should be the _time which I get from the sub search. I tried to give it as a variable but it dint work.

sourcetype=dg earliest=_time [search earliest=-7d sourcetype=dg (src_file_name="usb#flash disk" OR src_file_name="usb#mass storage") | dedup src_host, src_file_name | return src_host, _time]

I also tried the below query but it dint work

sourcetype=dg earliest=$_time [search earliest=-7d sourcetype=dg (src_file_name="usb#flash disk" OR src_file_name="usb#mass storage") | dedup src_host, src_file_name | return src_host, $_time]

Any help would be appreciated.

0 Karma

Ayn
Legend

The problem here is that _time is considered an internal field and as such will not be returned by the subsearch. I wrote about a way to work around this in another answer, available here: http://splunk-base.splunk.com/answers/52891/most-recent-event-from-each-source

0 Karma
Get Updates on the Splunk Community!

Splunk Education - Fast Start Program!

Welcome to Splunk Education! Splunk training programs are designed to enable you to get started quickly and ...

Five Subtly Different Ways of Adding Manual Instrumentation in Java

You can find the code of this example on GitHub here. Please feel free to star the repository to keep in ...

New Splunk APM Enhancements Help Troubleshoot Your MySQL and NoSQL Databases Faster

Splunk Observability has two new enhancements to make it quicker and easier to troubleshoot slow or frequently ...