Activate/Deactivate Watchers through Jenikins


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 -

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

(Alexander Reelsen) #2

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


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


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.

(Alexander Reelsen) #5

not the kibana dashboard, but the elasticsearch instance.

(system) closed #6

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