# Setup watcher with multiple must\_not values do not apply as expected

**URL:** <https://discuss.elastic.co/t/setup-watcher-with-multiple-must-not-values-do-not-apply-as-expected/256957>\
**Category:** Kibana\
**Created:** [November 28, 2020, 5:27pm UTC](https://discuss.elastic.co/t/setup-watcher-with-multiple-must-not-values-do-not-apply-as-expected/256957 "2020-11-28T17:27:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aviram\_Niron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aviram_niron/32/79853_2.png) [@Aviram\_Niron](https://discuss.elastic.co/u/Aviram_Niron)\
**Post date:** [November 28, 2020, 5:27pm UTC](https://discuss.elastic.co/t/setup-watcher-with-multiple-must-not-values-do-not-apply-as-expected/256957/1 "2020-11-28T17:27:06Z")

</div>

I've set the following watcher which aims to ignore events coming from several tenants (as indicated in the "must\_not" clause). However, these are not ignored. What am I missing?

```auto
{
      "trigger": {
    "schedule": {
      "interval": "1m"
    }
      },
      "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "hws-logs*"
        ],
        "rest_total_hits_as_int": true,
        "body": {
          "size": 0,
          "query": {
            "bool": {
              "must": [
                {
                  "match": {
                    "log_level.keyword": "FATAL"
                  }
                },
                {
                  "range": {
                    "@timestamp": {
                      "gte": "{{ctx.trigger.scheduled_time}}||-5m",
                      "lte": "{{ctx.trigger.scheduled_time}}",
                      "format": "strict_date_optional_time||epoch_millis"
                    }
                  }
                }
              ],
              "must_not": {
                "terms": {
                  "event.tenant_id": [
                    "ID_OF_TENANT001",
                    "ID_OF_TENANT002"
                  ]
                }
              }
            }
          }
        }
      }
    }
      },
      "condition": {
    "script": {
      "source": "if (ctx.payload.hits.total > params.threshold) { return true; } return false;",
      "lang": "painless",
      "params": {
        "threshold": 1
      }
    }
      },
      "actions": {
    "webhook_1": {
      "webhook": {
        "scheme": "https",
        "host": "HOSTNAME",
        "port": 443,
        "method": "post",
        "path": "api/v2/tickets/",
        "params": {},
        "headers": {},
        "auth": {
          "basic": {
            "username": "USERNAME",
            "password": "PASSWORD"
          }
        },
        "body": """{ "description": "ALERT - FATAL - Kibana", "subject": "Kibana Reporting", "email": "EMAIL@ADDRESS.COM", "priority": 1, "status": 2,"group_id":30000054182,"responder_id":30006940628,"type":"Task","custom_fields":{"cf_product":"Workspace"}}"""
      }
    }
      },
      "transform": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "hws-logs*"
        ],
        "rest_total_hits_as_int": true,
        "body": {
          "query": {
            "match": {
              "log_level.keyword": "FATAL"
            }
          }
        }
      }
    }
      }
    }

```

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [November 30, 2020, 9:57am UTC](https://discuss.elastic.co/t/setup-watcher-with-multiple-must-not-values-do-not-apply-as-expected/256957/2 "2020-11-30T09:57:30Z")

</div>

Can you change the `terms` to `term` in the `must_not` since you're only searching on one term?

---

<div class="post-metadata">

**Author:** ![Aviram\_Niron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aviram_niron/32/79853_2.png) [@Aviram\_Niron](https://discuss.elastic.co/u/Aviram_Niron)\
**Post date:** [November 30, 2020, 11:39am UTC](https://discuss.elastic.co/t/setup-watcher-with-multiple-must-not-values-do-not-apply-as-expected/256957/3 "2020-11-30T11:39:04Z")

</div>

Hi Marius,  
Thanks for the advice. Applying the change I get the following error:  
"error": {  
"root\_cause": [  
{  
"type": "parsing\_exception",  
"reason": "[term] query does not support array of values",

Please note that I have multiple tenants I'd like to filter out, not only one.  
Anything else you can suggest?

---

<div class="post-metadata">

**Author:** ![Aviram\_Niron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aviram_niron/32/79853_2.png) [@Aviram\_Niron](https://discuss.elastic.co/u/Aviram_Niron)\
**Post date:** [December 7, 2020, 2:51pm UTC](https://discuss.elastic.co/t/setup-watcher-with-multiple-must-not-values-do-not-apply-as-expected/256957/4 "2020-12-07T14:51:48Z")

</div>

Hi Marius,  
Thanks for the advice. Applying the change I get the following error:  
"error": {  
"root\_cause": [  
{  
"type": "parsing\_exception",  
"reason": "[term] query does not support array of values",

Please note that I have multiple tenants I'd like to filter out, not only one.  
Anything else you can suggest?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 4, 2021, 2:51pm UTC](https://discuss.elastic.co/t/setup-watcher-with-multiple-must-not-values-do-not-apply-as-expected/256957/5 "2021-01-04T14:51:59Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
