Trigger alert only between 2 date/time range

Dear All,

I saw some posts mon-fri 8am-9pm, tested with stream and it work fine but this is basic.

  1. Alert triger between 2 date/time range
    Adding this in where, work fine
    hour(“time”) >= 8 AND hour(“time”) <= 17 weekday(“time”) >=1 and weekday("time) <=5

But what we need its to trigger alert only between mon 1:30am to fri 23:35pm when application run basically, similar as ITRS time rule.

Basically something like below
(Weekday(“time”)>=1 and hour(“time”)>=1 and minute(“time”)>=30) and (weekday(“time”) <=5 and hour(“time”) <= 23 and minute(“time”) <= 35)

Your expertise and feedback on how to achieve above.

  1. Or as workaround using slideload

I tried as below even maintenance set to true on yml file and can see true in the log, alert is still triggered which should not be the case.

|sideload()
.source(‘file:///usr/kapacitor/scheduled-maintenance’)
.order(‘hosts/{{.host}}/{{.pattern}}.yml’)
.field(‘maintenance’, FALSE)

pattern1.yml

maintenance: true

stream
// …
|alert()
.crit(lambda: !“maintenance” AND “value” > 80)
.warn(lambda: !“maintenance” AND “value” > 70)

But what we need its to trigger alert only between mon 1:30am to fri
23:35pm when application run basically, similar as ITRS time rule.

I assume you mean “between 01:30 and 23:35 on each of five days a week” and not
“starting at 01:30 on Monday and finishing at 23:35 on Friday”.

Basically something like below
(Weekday(“time”)>=1 and hour(“time”)>=1 and minute(“time”)>=30) and
(weekday(“time”) <=5 and hour(“time”) <= 23 and minute(“time”) <= 35)

Let’s just break that down - the bracketing makes no difference since every
operator is AND.

weekday must be >=1
weekday must be <=5

hour must be >=1
hour must be <=23

minute must be >=30
minute must be <=35

So, that entire expression will be TRUE on Mondays to Fridays between the
times:

01:30 - 01:35
02:30 - 02:35
03:30 - 03:35 etc…

So, I think what you really want is:

weekday(time)>0 and weekday(time)<6 and
( (hour(time)=0 and minute(time)>29)
or (hour(time)>0 and hour(time)<23)
or (hour(time)=23 and minute(time)<36) )

Regards,

Antony.

Hi Pooh

I need to handle 2 situations

Weekly process as below.
“starting at 01:30 on Monday and finishing at 23:35 on Friday, thats a weekly process running.

Daily one as well

between 06:30 mon to fri 23:35 on each of five days a week”

Or even 06:30 mon to tues 04:00

Hi Pooh

I need to handle 2 situations

Oh, okay.

Weekly process as below.
“starting at 01:30 on Monday and finishing at 23:35 on Friday, thats a
weekly process running.

( (weekday(time)=1 and hour(time)=1 and minute(time)>29) or
(weekday(time)=1 and hour(time)>1) or
(weekday(time)>1 and weekday(time)<5) or
(weekday(time)=5 and hour(time)<23) or
(weekday(time)=5 and hour(time)=23 and minute(time)<36) )

Daily one as well

between 06:30 mon to fri 23:35 on each of five days a week”

Use the example I already gave - change the hour tests from 0 to 5.

Or even 06:30 mon to tues 04:00

( (weekday(time)=1 and hour(time)=6 and minute(time)>29) or
(weekday(time)=1 and hour(time)>6) or
(weekday(time)=2 and hour(time)<4) or
(weekday(time)=2 and hour(time)=4 and minute(time)=0) )

Regards,

Antony.

2 Likes

Thank you Antony for prompt reply. Have a good weekend and enjoy Fathers day.

I will try your recommendation first thing on Monday.
Keep you posted.

Cheers,
Martial

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.