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!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...