Splunk Search

Two earliest queries - want search to pick based upon newest

htkhtk
Path Finder

I have a query where I need to determine the earliest time I want events from.. It is either (1) The last time jboss started or (2) 30 minutes since the last event in the logs. (Whichever is closest to current time.)

How do i do that in a query most efficiently?

Here are the subsearches.

[search sourcetype="server_log" 
    | head 1 
    | eval test = relative_time(_time, "-30m@m") 
    | rename test as earliest 
    | fields earliest
] 


[search sourcetype="server_log" "starting service(s)" 
    | head 1 
    | rename _time as earliest
    | fields earliest
]

Thanks!

Tags (1)
1 Solution

southeringtonp
Motivator

How about this?

[ search sourcetype="server_log"
    | head 1
    | eval eventtime = relative_time(_time, "-30m@m")
    | append [ 
         search sourcetype="server_log" "starting service(s)"
         | head 1
         | rename _time as eventtime 
      ]
    | stats max(eventtime) as earliest
]

View solution in original post

0 Karma

southeringtonp
Motivator

How about this?

[ search sourcetype="server_log"
    | head 1
    | eval eventtime = relative_time(_time, "-30m@m")
    | append [ 
         search sourcetype="server_log" "starting service(s)"
         | head 1
         | rename _time as eventtime 
      ]
    | stats max(eventtime) as earliest
]
0 Karma
Get Updates on the Splunk Community!

Splunk Decoded: Service Maps vs Service Analyzer Tree View vs Flow Maps

It’s Monday morning, and your phone is buzzing with alert escalations – your customer-facing portal is running ...

What’s New in Splunk Observability – September 2025

What's NewWe are excited to announce the latest enhancements to Splunk Observability, designed to help ITOps ...

Fun with Regular Expression - multiples of nine

Fun with Regular Expression - multiples of nineThis challenge was first posted on Slack #regex channel ...