Splunk Search

How to set latest time dynamically in search

strive
Influencer

Hi,

We have a chart for which we get only earliest time from other chart. Whatever time we get, i want to make latest as earliest + 1 (1 is 1 day here).

How can we set latest time in search based on earliest time?

I am looking at something like index=IndexA earliest="09/09/2013:00:00:00" latest=earliest+1

Thanks

Strive

Tags (2)
1 Solution

dwaddle
SplunkTrust
SplunkTrust

There is a subsearch-based way of handling that here -- http://answers.splunk.com/answers/27784/latest-add-1-hour

View solution in original post

strive
Influencer

We are able to do this using sideview utils etime and ltime

lpolo
Motivator

Try this approach:

1-. Convert your earliest time to epoch time. Example: Assuming that this is your earliest time format "2013-08-25T18:42Z", you could converted to epoch time as follow in Splunk:

|eval earliest_epoch=strptime(earliest,"%Y-%m-%dT%H:%M")

2) Then, add 86400 seconds to the converted epoch time.

|eval latest=earliest_epoch+86400

0 Karma

dwaddle
SplunkTrust
SplunkTrust

There is a subsearch-based way of handling that here -- http://answers.splunk.com/answers/27784/latest-add-1-hour

strive
Influencer

I saw this link first and since you had mentioned "I hope that someone can provide a more elegant one." i was hoping if someone has already identified an elegant one 🙂 and posted this question. Your solution works perfectly fine. I will use it.

Thanks a lot.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

A Four-Part Event Series: Full Stack Observability For the AI Era

As AI reshapes applications, infrastructure, and the way teams operate, the traditional boundaries of ...

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...