Add a night time houres limit for alerts

hi all

i have the below tickscript for monitoring packet loss on a fortigate SD-WAN.
it all works well, but I’m trying to add a nighttime limit on the alerts so alerts won’t be sent during nighttime hours.
my server has kapasitor 1.5.5 installed on it, my sites are located in the US but my server configured timezone is GMT.
So I want to avoid sending alerts from 4:00:00 to 11:00:00 GMT.
I’ve tried to add a wherefilter or add more conditions to the crit lambda, but I couldn’t figure it out.

appreciate any Help/Tip.

thanks

var critp = 4

var crith = 20

var data = stream
    |from()
        .measurement('httpjson_sd_wan_stats')
        .where(lambda: "results_ping check_wan2_latency" > critp OR "results_http check_wan2_latency" > crith)
        .groupBy('location')
    //  .where(whereFilter1)
    // .where(whereFilter2)
    |eval(lambda: int("results_ping check_wan2_latency"), lambda: int("results_http check_wan2_latency"))
        .as('value1', 'value2')
        .keep()
    |window()
        .period(30s)
        .every(10s)
        .align()

var ping_alert = data
    |alert()
        .crit(lambda: "value1" > critp AND "value2" <= crith)
        .stateChangesOnly(30s)
        .message('Ping latency threshold reached for WAN_OPS in {{ index .Tags "location" }} with {{ index .Fields "value1"}}% {{ .Time }}')
        .slack()
        .channel('#alerts')
        .username('admin')
        .iconEmoji('⚠️')

var http_alert = data
    |alert()
        .crit(lambda: "value2" > crith AND "value1" <= critp)
        .stateChangesOnly(30s)
        .message('HTTP latency threshold reached for WAN_OPS in {{ index .Tags "location" }} with {{ index .Fields "value2"}}% {{ .Time }}')
        .slack()
        .channel('#alerts')
        .username('admin')
        .iconEmoji('⚠️')

var ping_http_alert = data
    |alert()
        .crit(lambda: "value1" > critp AND "value2" > crith)
        .stateChangesOnly(30s)
        .message('Ping latency threshold reached for WAN_OPS in {{ index .Tags "location" }} with {{ index .Fields "value1"}}% {{ .Time }}')
        .slack()
        .channel('#alerts')
        .username('admin')
        .iconEmoji('⚠️')

Any ideas here?

thanks

Hello @ahiyaz,
I’m sorry there isn’t much kapacitor support available for InfluxData anymore.
You could include that time condition in your crit() but I don’t think there’s a way to delay receiving the alert.