Hey there,
I am currently polling an endpoint over https for the cluster's health status, and I would like an alert sent if the returned status is a certain value and if it's not between certain times in the day (when our logs rotate, which causes a yellow status).
At first I tried this:
"condition": {
"compare": {
"ctx.payload.status": {
"eq": "yellow"
},
"ctx.execution_time": {
"gte": "<{now/d+5m}>"
}
}
},
However, although there was no error, the first condition isn't saved - if I reopen my Watcher the first one is gone.
I tried to rewrite it as a script, but that created a second issue:
"condition": {
"script": {
"source" : "return ( ctx.payload.status == params.color && ctx.execution_time > params.after)",
"params" : {
"color" : "yellow",
"after" : "now/d+5m"
}
}
},
I'm not sure how/whether I should be converting ctx.execution_time (what's an easy way to tell if it's a string or date type within a script?) and any parameters I pass seem to be treated as strings.
What's the best way to do this? Thanks in advance!