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!

Introduction to Splunk Observability Cloud - Building a Resilient Hybrid Cloud

Introduction to Splunk Observability Cloud - Building a Resilient Hybrid Cloud  In today’s fast-paced digital ...

Observability protocols to know about

Observability protocols define the specifications or formats for collecting, encoding, transporting, and ...

Take Your Breath Away with Splunk Risk-Based Alerting (RBA)

WATCH NOW!The Splunk Guide to Risk-Based Alerting is here to empower your SOC like never before. Join Haylee ...