Splunk Search

Custom Searches - 'Out of Hours' timeframe

iTUBS
New Member

Hi All,

I am currently trying to perform some monitoring, and am having a bit of trouble with the Splunk search engine.

I want to return results from an entire month, but from specific times during that month

  • Weekdays, after 8pm but before 8am
  • Weekends, 24 hours

Does anyone know how to build this sort of query?

Thanks in advance for any help!

Tags (1)
0 Karma

Ayn
Legend

Extract the week day and the hour from the timestamp, then check events that match your conditions. Something like this:

... | eval date_wday=strftime(_time,"%a") | eval date_hour=strftime(_time, "%H") | search (NOT (date_wday="Sat" OR date_wday="Sun") AND (date_hour>=20 OR date_hour<8)) OR date_wday="Sat" OR date_wday="Sun"

Note: the date_wday and date_hour fields are most often created automatically by Splunk, so if you're seeing that all your events already have these, you don't need to create themselves using eval like what I did above. However there are situations when they will not be created, so make sure first that you're not encountering that problem.

Get Updates on the Splunk Community!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...