Splunk Search

How do you exclude certain days from a time range?

Marinus
Communicator

If you have a time range and certain days contain data you'd like to exclude can you drop the days from your search result?

Tags (2)
2 Solutions

netwrkr
Communicator

To exclude wednesday you would add 'date_wday!=wednesday' to your search.

Check this article out for more information about the internal date fields -

http://www.splunk.com/base/Documentation/4.1/User/UseDefaultAndInternalFields

View solution in original post

Lowell
Super Champion

You could filter out events based on the _time field using a where search command. This is more difficult to setup that using date_wday, but it's very flexible.

The basic approach would be to preform your search, then grab the timerange of your searchs using the addinfo search command. Then use the where search to filter out the unwanted events in the middle of your search range.

For example, say you were searching over a 1 hour window, but want to remove the center 30 minutes (so remove events between 15 after to 45 minutes after), you could do a search like this:

<your search> earliest=-1h@h latest=@h | addinfo | where _time < (info_min_time+900) OR _time > (info_max_time-900)

Some additional thoughts:

Along with info_min_time, info_max_time which I used in this example, there is also info_search_time which could be used if you wanted to do some time operations relative to the system time when you run your search.

Note that you can also use _indextime here, if you wanted to look at when your events were actually indexed rather than when your events occurred; which is sometimes interesting to look at.

View solution in original post

Lowell
Super Champion

You could filter out events based on the _time field using a where search command. This is more difficult to setup that using date_wday, but it's very flexible.

The basic approach would be to preform your search, then grab the timerange of your searchs using the addinfo search command. Then use the where search to filter out the unwanted events in the middle of your search range.

For example, say you were searching over a 1 hour window, but want to remove the center 30 minutes (so remove events between 15 after to 45 minutes after), you could do a search like this:

<your search> earliest=-1h@h latest=@h | addinfo | where _time < (info_min_time+900) OR _time > (info_max_time-900)

Some additional thoughts:

Along with info_min_time, info_max_time which I used in this example, there is also info_search_time which could be used if you wanted to do some time operations relative to the system time when you run your search.

Note that you can also use _indextime here, if you wanted to look at when your events were actually indexed rather than when your events occurred; which is sometimes interesting to look at.

netwrkr
Communicator

To exclude wednesday you would add 'date_wday!=wednesday' to your search.

Check this article out for more information about the internal date fields -

http://www.splunk.com/base/Documentation/4.1/User/UseDefaultAndInternalFields

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...