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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...