Splunk Search

How to exclude logs with specific time ranges from a search?

karlduncans
Engager

Hello,

I'd like to exclude a specific time range from appearing in a search.

I have a custom time stamp field in these particular logs. example: timestamp='2014-06-22 T 01:48:12.6942440'

index=myindex sourcetype="my_source" TimeStampField!=?? | top 20 Errors

I'd want to exclude all logs with a timestamp of say, 2am to 6am every day, and if possible exclude different time ranges depending on the day.

For example, exclude all logs from 2am to 6am on weekdays, and exclude all logs on weekends from sat 10pm to sunday 6am.

Thank you!

Tags (2)
0 Karma

somesoni2
Revered Legend

You can try something like this

index=myindex sourcetype="my_source" | eval shouldInclude=case((date_wday="monday" OR date_wday="tuesday" OR date_wday="wednesday" OR date_wday="thursday" OR date_wday="friday") AND (date_hour >=2 AND date_hour<=6),0,date_wday="saturday" AND date_hour >=10 ,0,date_wday="sunday" AND date_hour<=6,0,1=1,1) | where shouldInclude=1 | top 20 Errors
0 Karma
Get Updates on the Splunk Community!

Modern way of developing distributed application using OTel

Recently, I had the opportunity to work on a complex microservice using Spring boot and Quarkus to develop a ...

Enterprise Security Content Update (ESCU) | New Releases

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

Archived Metrics Now Available for APAC and EMEA realms

We’re excited to announce the launch of Archived Metrics in Splunk Infrastructure Monitoring for our customers ...