# Watcher Kibana : How can i use double condition in a "compare"

**URL:** <https://discuss.elastic.co/t/watcher-kibana-how-can-i-use-double-condition-in-a-compare/170999>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [March 5, 2019, 10:56pm UTC](https://discuss.elastic.co/t/watcher-kibana-how-can-i-use-double-condition-in-a-compare/170999 "2019-03-05T22:56:02Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![andres-perez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andres-perez/32/136461_2.png) [@andres-perez](https://discuss.elastic.co/u/andres-perez)\
**Post date:** [March 6, 2019, 5:55pm UTC](https://discuss.elastic.co/t/watcher-kibana-how-can-i-use-double-condition-in-a-compare/170999/2 "2019-03-06T17:55:31Z")

</div>

Hi,

I don't understand well the extra condition you want to add

> [@hmezoughi](#):
>
> at least 50 totals hits already on the last 15 minutes

Your current input query looks for `"ERROR"` value for the field `"STATE"` from the last 15 minutes.

If you want to look for different data in the same watch, you can use [chain inputs](https://www.elastic.co/guide/en/elastic-stack-overview/current/input-chain.html).

There is a thread in this forum with a full example: [A watch alert example based on two different searches using CHAIN input and Painless script condition](https://discuss.elastic.co/t/a-watch-alert-example-based-on-two-different-searches-using-chain-input-and-painless-script-condition/113829)

For example, you can set

- One search input named _"errors"_ with your current query
- Another one named _"all\_messages"_ with a similar query minus the `"ERROR"` filter to get all messages in the last 15 minutes.

Customize them with your desired searches.

Then, you may use a [script condition](https://www.elastic.co/guide/en/elastic-stack-overview/current/condition-script.html) to be able to evaluate two conditions.

Something like:

```
  "condition": {
    "script": {
      "source": "return ctx.payload.errors.hits.total >= 15 && ctx.payload.all_messages.hits.total >= 50",
      "lang": "painless"
    }

```

---

_[View the full topic](https://discuss.elastic.co/t/watcher-kibana-how-can-i-use-double-condition-in-a-compare/170999)._
