# Updating watchers via API doesn't take affect without manual intervention

**URL:** <https://discuss.elastic.co/t/updating-watchers-via-api-doesnt-take-affect-without-manual-intervention/158147>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [November 26, 2018, 9:40am UTC](https://discuss.elastic.co/t/updating-watchers-via-api-doesnt-take-affect-without-manual-intervention/158147 "2018-11-26T09:40:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Magnus\_Therning](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnus_therning/32/33091_2.png) [@Magnus\_Therning](https://discuss.elastic.co/u/Magnus_Therning)\
**Post date:** [November 26, 2018, 9:40am UTC](https://discuss.elastic.co/t/updating-watchers-via-api-doesnt-take-affect-without-manual-intervention/158147/1 "2018-11-26T09:40:42Z")

</div>

In an attempt to get some control over our alerting we have put our watcher definitions in a GitHub repo and put together a build script so Travis deploys updates to the watchers automatically. This seems to work only only half-way in the sense that

- the new watchers are deployed to our elasticsearch instance on [elastic.co](http://elastic.co), and
- the GUI says that the watchers are run, however
- the watchers never actually fire

The only way we've found to "turn them on" is to manually log in to elasticsearch/kibana, and manually save each watcher.

This is not really the behaviour we expected, so we suspect there's something we are missing.

This is how we put the put a watcher on our elasticsearch instance:

```
put_watch() {
    local filename=$1
    local watch_name=$(basename $filename .json)

    # This is the Elasticsearch endpoint for our deployment.
    local host=<elastic.co id>.eu-central-1.aws.cloud.es.io:9243

    local url=https://$host/_xpack/watcher/watch
    http -a "<user>:<pword>" PUT $url/$watch_name < $filename
}

```

The instance in question is running version 6.2.4.

---

<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:** [November 26, 2018, 4:30pm UTC](https://discuss.elastic.co/t/updating-watchers-via-api-doesnt-take-affect-without-manual-intervention/158147/2 "2018-11-26T16:30:23Z")

</div>

can you share the actual HTTP requests you are sending?

So far I have not seen, what is being sent to the elasticsearch node, and that would be vital for further debugging.

--Alex

---

<div class="post-metadata">

**Author:** ![Magnus\_Therning](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnus_therning/32/33091_2.png) [@Magnus\_Therning](https://discuss.elastic.co/u/Magnus_Therning)\
**Post date:** [November 26, 2018, 9:56pm UTC](https://discuss.elastic.co/t/updating-watchers-via-api-doesnt-take-affect-without-manual-intervention/158147/3 "2018-11-26T21:56:22Z")

</div>

Of course. One of them you can find one at [http://termbin.com/trqx](http://termbin.com/trqx).

---

<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:** [November 27, 2018, 8:10am UTC](https://discuss.elastic.co/t/updating-watchers-via-api-doesnt-take-affect-without-manual-intervention/158147/4 "2018-11-27T08:10:36Z")

</div>

thanks for the link.

this is only the request body, but does not give an indication of what was really sent. Can you run `curl -v` (or the equivalent of your `http` tool) to also see headers and responses?

Thanks!

---

<div class="post-metadata">

**Author:** ![Magnus\_Therning](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnus_therning/32/33091_2.png) [@Magnus\_Therning](https://discuss.elastic.co/u/Magnus_Therning)\
**Post date:** [November 27, 2018, 8:38am UTC](https://discuss.elastic.co/t/updating-watchers-via-api-doesnt-take-affect-without-manual-intervention/158147/5 "2018-11-27T08:38:30Z")

</div>

Here's a full exchange, both full request and full response: [http://termbin.com/b8s3](http://termbin.com/b8s3).

(I should point out that I copied it from Travis, and there may be some escape codes for colours that have come through because, well, Travis kind of sucks sometimes.)

---

<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:** [November 27, 2018, 9:01am UTC](https://discuss.elastic.co/t/updating-watchers-via-api-doesnt-take-affect-without-manual-intervention/158147/6 "2018-11-27T09:01:02Z")

</div>

this looks fine and should execute as you expect it to be.

Did you check the watch history if no executions at all happened? Each execution of a watch has a so called watch record.

```auto
GET .watcher-history-*/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "watch_id": "bull-prod-errors"
          }
        }
      ]
    }
  },
  "sort": [
    {
      "trigger_event.triggered_time": {
        "order": "desc"
      }
    }
  ]
}

```

Does the above return anything?

---

<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 25, 2018, 9:01am UTC](https://discuss.elastic.co/t/updating-watchers-via-api-doesnt-take-affect-without-manual-intervention/158147/7 "2018-12-25T09:01:08Z")

</div>

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