Splunk Search

EVAL separate search for Monday

davidcraven02
Communicator

Each Monday the event count for skypeuk is 30 and skypeus is 200. However, for the rest of the weekday skypeuk is atleast is 290 and skypeus is 700.

How would I build in a new search to the one below to accommodate this low event count on Monday?

| tstats count as "Data Received" where index=msexchange host=opspkhf03p    source=skypeuk
| eval result=if('Data Received'> 200, "PASS", "FAIL")
| eval host="opspkhf03p"
| append 
    [| tstats count as "Data Received" where  index=msexchange   host=opspkhf03p source=skypeus
| eval result=if('Data Received'> 700, "PASS", "FAIL")
| eval host="opspkhf03p"]
| table host, "Data Received", result
Tags (2)
0 Karma
1 Solution

tiagofbmm
Influencer

You can do the tstats by _time and then evaluate if it is a Monday or not:

| tstats count where index=_internal by _time span=1d
| eval date_wday=strftime(_time,"%A")
| eval result=if(count> 700 AND date_wday=="Monday", "PASS", "FAIL")

View solution in original post

davidcraven02
Communicator

Thanks I appreciate your help on this. Now I'm receiving two rows and both are FAIL when running with Last 24 hours

alt text

0 Karma

tiagofbmm
Influencer

That is happening because your search is also going through the 25th of March which is Sunday.

If in the end you put the date_wday in the table you will get one row for Sunday and another for Monday.

If you just want the data for Monday, then just filter that one out like I;m showing below. If not, just have the results per date_wday where you can see Monday results but also any other days you want. It is up to you.

  |  tstats count as "Data Received"  where  index=msexchange     host=opspkhf03p source=skypeuk by _time  span =1d 
 | eval date_wday=strftime(_time,"%A")
  | where date_wday=="Monday"
  | eval result=if(count> 30 AND date_wday=="Monday", "PASS", "FAIL")
  | eval host="opspkhf03p"
0 Karma

tiagofbmm
Influencer

You can do the tstats by _time and then evaluate if it is a Monday or not:

| tstats count where index=_internal by _time span=1d
| eval date_wday=strftime(_time,"%A")
| eval result=if(count> 700 AND date_wday=="Monday", "PASS", "FAIL")

davidcraven02
Communicator

Thanks for this. I ran this but it is saying fail with the below search. When adding date_wday to the table it has no value.

| tstats count as "Data Received" where  index=msexchange     host=opspkhf03p source=skypeuk
 | eval date_wday=strftime(_time,"%A")
 | eval result=if(count> 30 AND date_wday=="Monday", "PASS", "FAIL")
 | eval host="opspkhf03p"
   | append 
     [| tstats count as "Data Received" where  index=msexchange     host=opspkhf03p source=skypeus
 | eval date_wday=strftime(_time,"%A")
 | eval result=if(count> 200 AND date_wday=="Monday", "PASS", "FAIL")
 | eval host="opspkhf03p"]
 | table host, "Data Received", result
0 Karma

davidcraven02
Communicator

Thank you very much, this worked!

0 Karma

tiagofbmm
Influencer

Yes because your did not put the tstats by _time

| tstats count where index=_internal by _time span=1d
| eval date_wday=strftime(_time,"%A")
| eval result=if(count> 700 AND date_wday=="Monday", "PASS", "FAIL")

0 Karma

davidcraven02
Communicator

How can I run

 | tstats count where index=_internal by _time span=1d 

with my first line

|  tstats count as "Data Received" where  index=msexchange     host=opspkhf03p source=skypeuk

They don't run together. Am I explaining myself correctly?

0 Karma

tiagofbmm
Influencer

They can run together of you put it like this

 |  tstats count as "Data Received"  where  index=msexchange     host=opspkhf03p source=skypeuk by _time  span =1d 
0 Karma

tiagofbmm
Influencer

Hey

What exactly do you want to achieve here?
What do you want to do with the Monday case? Is it different? Do you have different PASS/FAIL thresholds you want to have just for Mondays?

0 Karma

davidcraven02
Communicator

I would like for it to check if it is Monday and use the below pseudo-code logic

for skypeuk
If dayOfWeek=Monday
check if event count (Data Received) is greater than equals 290 then PASS else FAIL

for skypeus
If dayOfWeek=Monday
check if event count (Data Received) is greater than equals 700 then PASS else FAIL

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...