Adding multiple conditions in a Kibana watcher

Hello everyone,

I need to set up a watcher in Kibana with the following conditions:
a. Trigger an alert when the threshold reaches 100 between 6 AM and 11 AM. b. Trigger an alert when the threshold reaches 400 during other times.

Note: This should be done in a single watcher.

Here is the condition script:

"condition": {
  "script": {
    "source": "if (ctx.payload.hits.total <= 100 && (ctx.trigger.triggered_time.getHour() >= 6 && ctx.trigger.triggered_time.getHour() <= 11)) { return true; } else if (ctx.payload.hits.total <= 400) { return true; } else { return false; }",
    "lang": "painless"
  }
}

Hi,

Your condition script seems to be on the right track. However, there seems to be a small mistake in your condition. You are using <= operator for the threshold values, but based on your requirements, you should use >=

Regards

Good Afternoon,

I tried with your suggestion as well. but still it's not working. Could you please provide an alternate approach.

Thanks,
Neha