Splunk Search

how to keep the earliest time as constant and latest as current time (now) without using token and timerangepicker?

mprreddy51
Explorer

Hi,

how to keep the earliest time as constant(Say 12.00AM) and latest as current time (now)in splunk dashboard? requirement is without using timerange picker or token. My earliest time is fixed every day only latest will change.

example: If i open my dashboard at morning 4.00 am then I should be able to see 4.00hrs data (from 12.00 am to 4.00am) or if you open at 8 am then you should be able to see 8 hrs data(12.00 am to 8.00 am).

Thanks in advance.

0 Karma
1 Solution

Richfez
SplunkTrust
SplunkTrust

You should be able to use "earliestTime=X" type commands in your simplexml for each search. Please see here, the first example I think would cover your needs.

View solution in original post

0 Karma

woodcock
Esteemed Legend

You need the bucket (or relative_time) and now functions, as well as subsearches.

Something like this:

Your base search here earliest=[|noop | stats count AS noon | eval now=now() | eval noon = now | bucket noon span=1d | eval noon = noon + (12*60*60) | eval noon = if((now > noon), noon, noon - (24*60*60)) | return $noon] latest=[|noop | stats count AS now | eval now=now() | return $now] | The rest of your stuff here
0 Karma

Richfez
SplunkTrust
SplunkTrust

You should be able to use "earliestTime=X" type commands in your simplexml for each search. Please see here, the first example I think would cover your needs.

0 Karma

mprreddy51
Explorer

Thanks for your response....that example will give from now to 24 hours.That not my requirement.earliestTime time should be fixed(at 12.00 am or 1.00 am. and latest is now(when you open dashboard).

0 Karma

Richfez
SplunkTrust
SplunkTrust

Sorry, I should have mentioned that it's only a sample, you'll have to modifiy it with the time modifiers to fit your needs.

You'll want something more like "@d" for your earliestTime to snap to the current "day". Not "-@d" and not "-d", just "@d".

FYI, -@d says to subtract a day then find the point at which one day becomes the next and use that as the earliest. -d says go back one day, that's not what you need either. @d says to go back to the beginning of today and start there.

0 Karma
Get Updates on the Splunk Community!

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to Officially Supported Splunk ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI! Discover how Splunk’s agentic AI ...