# Help with Advanced Watcher

**URL:** <https://discuss.elastic.co/t/help-with-advanced-watcher/210201>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [December 2, 2019, 2:40pm UTC](https://discuss.elastic.co/t/help-with-advanced-watcher/210201 "2019-12-02T14:40:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cho1409](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cho1409/32/44358_2.png) [@Cho1409](https://discuss.elastic.co/u/Cho1409)\
**Post date:** [December 2, 2019, 2:40pm UTC](https://discuss.elastic.co/t/help-with-advanced-watcher/210201/1 "2019-12-02T14:40:04Z")

</div>

Hi guys,

I'm trying to create a watcher for a simple query that goes like this:

```
field: "service_X" and event.level: "ERROR"

```

The problem is, when creating the watcher itself, it doesn't allow me to use multiple fields:

```
"input": {
"search": {
  "request": {
    "search_type": "query_then_fetch",
    "indices": [
      "whatever-logs-*"
    ],
    "rest_total_hits_as_int": true,
    "body": {
      "size": 0,
      "query": {
        "bool": {
          "filter": [
            {
              "range": {
                "@timestamp": {
                  "from": "now-10m",
                  "to": "now"
                }
              }
            },
            {
              "multi_match": {
                "query": "field_X: 'service_X' and event.level: 'ERROR'",
                "fields": ["field_X", "event.level"]
              }                  
            }
          ]
        }
      },
      "aggs": {
        "whatever_errors": {
          "cardinality": {
            "field": "field_X",
            "field":"event.level"
          }              
        }
      }
    }
  }
}

```

},  
"condition": {  
"always": {}  
},  
"actions": {  
"send\_to\_whatever": {  
"transform": {  
"script": {  
"source": "return ['sms\_errors': ctx.payload.aggregations.whatever\_errors.value]",  
"lang": "painless"  
}  
},

The error I'm getting from the simulation is // Failed to transform payload  
Like there's something related to the transform part.

Thank you.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [December 2, 2019, 3:00pm UTC](https://discuss.elastic.co/t/help-with-advanced-watcher/210201/2 "2019-12-02T15:00:19Z")

</div>

can you share the output of the [execute watch API](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/watcher-api-execute-watch.html)?

Also, please make sure, your whole snippet is formatted, this makes it a million times easier to read.

Thank you!

---

<div class="post-metadata">

**Author:** ![Cho1409](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cho1409/32/44358_2.png) [@Cho1409](https://discuss.elastic.co/u/Cho1409)\
**Post date:** [December 2, 2019, 7:40pm UTC](https://discuss.elastic.co/t/help-with-advanced-watcher/210201/3 "2019-12-02T19:40:30Z")

</div>

Nevermind, looks like we have a timeout issue with the entire cluster, shards are over 100GB. We gotta take care of it first before setting up watchers/searches.

Thank you!

---

<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:** [December 30, 2019, 7:40pm UTC](https://discuss.elastic.co/t/help-with-advanced-watcher/210201/4 "2019-12-30T19:40:40Z")

</div>

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