# Adding multiple conditions in a Kibana watcher

**URL:** <https://discuss.elastic.co/t/adding-multiple-conditions-in-a-kibana-watcher/359897>\
**Category:** Kibana\
**Tags:** elastic-stack-alerting, painless\
**Created:** [May 21, 2024, 9:03am UTC](https://discuss.elastic.co/t/adding-multiple-conditions-in-a-kibana-watcher/359897 "2024-05-21T09:03:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neha2](https://avatars.discourse-cdn.com/v4/letter/n/a4c791/32.png) [@Neha2](https://discuss.elastic.co/u/Neha2)\
**Post date:** [May 21, 2024, 9:03am UTC](https://discuss.elastic.co/t/adding-multiple-conditions-in-a-kibana-watcher/359897/1 "2024-05-21T09:03:09Z")

</div>

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:

```auto
"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"
  }
}

```

---

<div class="post-metadata">

**Author:** ![yago82](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yago82/32/97755_2.png) [@yago82](https://discuss.elastic.co/u/yago82)\
**Post date:** [May 22, 2024, 3:04pm UTC](https://discuss.elastic.co/t/adding-multiple-conditions-in-a-kibana-watcher/359897/2 "2024-05-22T15:04:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Neha2](https://avatars.discourse-cdn.com/v4/letter/n/a4c791/32.png) [@Neha2](https://discuss.elastic.co/u/Neha2)\
**Post date:** [May 24, 2024, 8:11am UTC](https://discuss.elastic.co/t/adding-multiple-conditions-in-a-kibana-watcher/359897/3 "2024-05-24T08:11:49Z")

</div>

Good Afternoon,

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

Thanks,  
Neha
