Splunk Search

How to exclude events if results from entire day returns zero?

dzyfer
Path Finder

I need to exclude events from a timechart only if they fulfill 2 conditions:

the field returns 0 for ALL events in the entire day (24hours) AND the days are weekends (Saturday & Sunday)

I have tried 

| date_wkend = strftime(_time,"%A")
| search NOT (date_wkend = "Saturday" AND varA = 0)
| search NOT (date_wkend = "Sunday" AND varA = 0)

However this also excludes the events from a weekend that has some non-zero results for varA, and since I have to do some further calculations based on a full-day span, my calculations are inaccurate.

Labels (5)
0 Karma
1 Solution

PickleRick
SplunkTrust
SplunkTrust

Half of the solution is almost there (filtering on weekday). You need the other half. Something like that if you want to account for the events which do not have my_var values at all, you'd probably have to fiddle with fillnull.

| date_wkend = strftime(_time,"%A")
| bin _time span=1d as timehelper
| eventstats dc(my_var) as dc by timehelper
| where NOT ((date_wkend="saturday" OR date_wkend="sunday") AND dc=1 AND my_var=0)

 

View solution in original post

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Half of the solution is almost there (filtering on weekday). You need the other half. Something like that if you want to account for the events which do not have my_var values at all, you'd probably have to fiddle with fillnull.

| date_wkend = strftime(_time,"%A")
| bin _time span=1d as timehelper
| eventstats dc(my_var) as dc by timehelper
| where NOT ((date_wkend="saturday" OR date_wkend="sunday") AND dc=1 AND my_var=0)

 

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

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