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!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...