Splunk Search

Exclude events which occur during a specific hour each day

benjwarner
Explorer

Hi there,
I have a query whereby I wish to return results over the previous week, but NOT within a specific couple of hours every day. At the moment it looks something like this:

source="*prod-*.log" earliest=-7d@w0 latest=@w7 | where NOT (date_hour>=9 AND date_hour<=11) | stats count by eventtype

However it is not excluding those events which fall between 9 and 11 each day.

If possible, I'd also like to know how to also specify the minutes in the query. e.g.

source="*prod-*.log" earliest=-7d@w0 latest=@w7 | where NOT (time>=9:58 AND time<=10:15) | stats count by eventtype

Please note, I've invented the "time" keyword above to demonstrate what I'm after.

Any help would be appreciated.
Cheers,
Ben

Tags (2)

lukeh
Contributor

Should be:
| where NOT ( (myHour >= 17 AND myMinute >= 00) OR (myHour < 19 AND myMinute <= 59) )

Luke 🙂

0 Karma

Damien_Dallimor
Ultra Champion

This example excludes events between 17:00pm(inclusive) and 19:00pm(exclusive). Substitute in the date params you want (not sure if your example in your question is AM or PM)

source="*prod-*.log" earliest=-7d@w0 latest=@w7 | eval myHour=strftime(_time, "%H") | eval myMinute=strftime(_time, "%M") | where NOT ( (myHour >= 17 AND myMinute >= 00) AND (myHour < 19 AND myMinute <= 59) )
0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...