Getting Data In

Count the number of events but avoid counting weekend days

mtmoore
Explorer

How would one filter out weekends in a count of events based on a search? Filter so that those days are not included in anyway... i.e. avoiding 0s in your final output due to the weekends.

Tags (2)
0 Karma

somesoni2
Revered Legend

Try out following

index="MSExchange" sourcetype="MSExchange:2010:MessageTracking" eventtype="storedriver-deliver"  | timechart count as NoofMessages | eval date_wday=lower(strftime(_time,"%A")) |where NOT (date_wday=saturday OR date_wday=sunday) | fields - date_wday| predict NoofMessages future_timespan=180

mtmoore
Explorer

That was the answer but with one modification... date_wday=saturday etc... the day needed to be surrounded in quotes i.e. date_wday="saturday". Thankyou very much!

0 Karma

royimad
Builder

Using the predefined date_wday on the events you can exclude weekends

sourcetype="testcsvlog" (date_wday=monday OR date_wday=tuesday OR date_wday=wednesday OR date_wday=thursday OR date_wday=friday) | ....

mtmoore
Explorer

throw everything out for |predict.

How can this be avoided?

0 Karma

mtmoore
Explorer

The problem with the above is that it replaces the 2 days with 0s. Therefore, if you pipe the search into |predict, it skewers the results.. I want those 2 days totally removed from the equation.

Here is my search:

index="MSExchange" sourcetype="MSExchange:2010:MessageTracking" eventtype="storedriver-deliver" (date_wday=monday OR date_wday=tuesday OR date_wday=wednesday OR date_wday=thursday OR date_wday=friday) | timechart count as NoofMessages | predict NoofMessages future_timespan=180

In the above example for your search data you get Fri 1000, Sat 0, Sunday 0, Tues 2500... the 0s

0 Karma
Get Updates on the Splunk Community!

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...

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 ...