# Elastic Search watcher is not working

**URL:** https://discuss.elastic.co/t/elastic-search-watcher-is-not-working/217661
**Category:** Elasticsearch
**Created:** [February 3, 2020, 4:27pm UTC](https://discuss.elastic.co/t/elastic-search-watcher-is-not-working/217661 "2020-02-03T16:27:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Abdulhadi](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@Abdulhadi](https://discuss.elastic.co/u/Abdulhadi)
#### Post date: [February 3, 2020, 4:27pm UTC](https://discuss.elastic.co/t/elastic-search-watcher-is-not-working/217661/1 "2020-02-03T16:27:41Z")

</div>

Hi All  
I am trying to build a JSON file for Watcher that will send an email whenever an account for Error logs exceed 80. But it continues giving an Error message  
This is the Built JSON file:  
PUT \_watcher/watch/feb6b01f-3fbe-4705-8847-914c89053029

{

"trigger": {

```
"schedule": {

  "interval": "1m"

}

```

},

"input": {

```
"search": {

  "request": {

    "body": {

      "size": 0,

      "query": {

        "bool": {

          "filter": {

            "range": {

              "@timestamp": {

                "gte": "{{ctx.trigger.scheduled_time}}||-1h",

                "lte": "{{ctx.trigger.scheduled_time}}",

                "format": "strict_date_optional_time||epoch_millis"

              }

            }

          }

        }

      },

      "aggs": {

        "bucketAgg": {

          "terms": {

            "field": "error.keyword",

            "size": "5",

            "order": {}

          }

        }

      }

    },

    "indices": [

      "gfx-prod-logs*"

    ]

  }

}

```

},

"condition": {

```
"script": {

  "source": "if (ctx.payload.hits.total > params.threshold) { return true; } return false;",

  "params": {

    "threshold": 80

  }

}

```

},

"transform": {

```
"script": {

  "source": "HashMap result = new HashMap(); result.result = ctx.payload.hits.total; return result;",

  "params": {

    "threshold": 80

  }

}

```

},

"actions": {

```
"email_1": {

  "email": {

    "profile": "standard",

    "to": [

      "Abdulhadi.b@gmail.com"

    ],

    "subject": "Kibana Alert GFX Prod Error ",

    "body": {

      "text": "Kibana Alert GFX Prod Error GTe 80"

    }

  }

}

```

}

}

Any Ideas, the error message are:  
"messages": [  
"failed to execute watch input"

And :  
"input": {  
"type": "search",  
"status": "failure",  
"error": {  
"root\_cause": [  
{  
"type": "parsing\_exception",  
"reason": "Must specify at least one field for [order]"

Thanks in Advance  
Regards

---

<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: [March 2, 2020, 4:27pm UTC](https://discuss.elastic.co/t/elastic-search-watcher-is-not-working/217661/2 "2020-03-02T16:27:45Z")

</div>

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