# Activate/Deactivate Watchers through Jenikins

**URL:** <https://discuss.elastic.co/t/activate-deactivate-watchers-through-jenikins/146531>\
**Category:** Elasticsearch\
**Created:** [August 29, 2018, 12:46pm UTC](https://discuss.elastic.co/t/activate-deactivate-watchers-through-jenikins/146531 "2018-08-29T12:46:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheCodingKnight](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@TheCodingKnight](https://discuss.elastic.co/u/TheCodingKnight)\
**Post date:** [August 29, 2018, 12:46pm UTC](https://discuss.elastic.co/t/activate-deactivate-watchers-through-jenikins/146531/1 "2018-08-29T12:46:12Z")

</div>

I have a number of watchers configured in Elastic which I would like to activate/deactivate in one go. I'm planning to create a Jenkins job and use the below APIs.

PUT \_xpack/watcher/watch/_watcherid_/\_deactivate  
PUT \_xpack/watcher/watch/_watcherid_/\_activate

However, how do I go about the authentication part? Based on the article here, any token will be valid only for a limited time - [https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html)

I'm probably missing something here. Could you help please?

---

<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:** [August 29, 2018, 1:54pm UTC](https://discuss.elastic.co/t/activate-deactivate-watchers-through-jenikins/146531/2 "2018-08-29T13:54:24Z")

</div>

Using the token API you still need your password to generate an initial token. and then refresh that one.

If you do not want to store a password you could use the PKI realm. See [https://www.elastic.co/guide/en/elasticsearch/reference/6.4/configuring-pki-realm.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/configuring-pki-realm.html)

---

<div class="post-metadata">

**Author:** ![TheCodingKnight](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@TheCodingKnight](https://discuss.elastic.co/u/TheCodingKnight)\
**Post date:** [August 29, 2018, 2:53pm UTC](https://discuss.elastic.co/t/activate-deactivate-watchers-through-jenikins/146531/3 "2018-08-29T14:53:27Z")

</div>

Thanks. Are there any examples around of invoking elastic Rest API calls externally (like through Jenkins?)

---

<div class="post-metadata">

**Author:** ![TheCodingKnight](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@TheCodingKnight](https://discuss.elastic.co/u/TheCodingKnight)\
**Post date:** [September 4, 2018, 5:22pm UTC](https://discuss.elastic.co/t/activate-deactivate-watchers-through-jenikins/146531/4 "2018-09-04T17:22:11Z")

</div>

> [@TheCodingKnight](#):
>
> ve a number of watchers configured in Elastic which I would like to activate/deactivate in

Hi @spinscale,  
Going through a few posts on the forums, I'm assuming I should be able to provide the username/password as part of the cURL command similar to below. Can you confirm on this please? Last question then, my Jenkins resides on a different server than where the ELK components are hosted. So the localhost & port part is not going to be valid. Should the hostname be the same that I use to view the Kibana dashboard?

> curl --user rdeniro:taxidriver -XPUT 'localhost:9200/idx'

Thanks in advance.

---

<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:** [September 5, 2018, 1:32pm UTC](https://discuss.elastic.co/t/activate-deactivate-watchers-through-jenikins/146531/5 "2018-09-05T13:32:54Z")

</div>

not the kibana dashboard, but the elasticsearch instance.

---

<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:** [October 3, 2018, 1:43pm UTC](https://discuss.elastic.co/t/activate-deactivate-watchers-through-jenikins/146531/6 "2018-10-03T13:43:26Z")

</div>

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