Splunk Search

Want to fetch data of 3 weeks, before any date and time entered

intelsubham
Explorer

Working on development of a form based dashboard where user will enter a date, and I want to fetch 3 weeks data before that date.so what should be the earliest and latest accordingly?

Example: suppose user entered 7/14/2014:00:00:00, data should be fetched for 3-weeks before that date.

Tags (3)
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

You could calculate the earliest_time in an eval-based macro like this:

index=foo sourcetype=bar earliest_time=`three_weeks_before($date$)` latest_time="$date$" | ...

With the macro three_weeks_before(1) defined like this:

relative_time(strptime("$date$", "%m/%d/%Y:%H:%M:%S"), "-3w")

View solution in original post

martin_mueller
SplunkTrust
SplunkTrust

You could calculate the earliest_time in an eval-based macro like this:

index=foo sourcetype=bar earliest_time=`three_weeks_before($date$)` latest_time="$date$" | ...

With the macro three_weeks_before(1) defined like this:

relative_time(strptime("$date$", "%m/%d/%Y:%H:%M:%S"), "-3w")
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 ...