Splunk Search

Time Snapping to the nearest day & Time Charting

marquiselee
Path Finder

I have a script that runs overnight everyday checking for 404 errors against a list of files. Each attempt to access the file is timestamped and marked successful or not_found. The script begins at around 9PM (give or take a couple of hours) and takes 6-8 hours to finish.

The issue I'm having is time charting for a week and beyond.

While the script may have started last night I need to have those results aggregated with the rest of the results and count as "Today's" results.

Is there a way to make the results 'snap' to the closest day?

e/g a 9PM or 11PM result on 1/17 would snap to 1/18 (12:01 AM) on the time chart AND a 3AM or 5 AM result on 1/18 would also snap to 1/18 (12:01 AM) on the time chart.

I hope this description makes sense.

Tags (3)
0 Karma
1 Solution

jonuwz
Influencer

Yes.

If you add 12 hours then round down, you'll snap to the nearest day.

The code would be :

... | eval _time=_time+(12*60*60) | bin _time span=1d | ...

View solution in original post

0 Karma

jonuwz
Influencer

Yes.

If you add 12 hours then round down, you'll snap to the nearest day.

The code would be :

... | eval _time=_time+(12*60*60) | bin _time span=1d | ...
0 Karma

marquiselee
Path Finder

like a glove! thnx

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...