# Setting value by reading from a file

**URL:** https://discuss.elastic.co/t/setting-value-by-reading-from-a-file/65280
**Category:** Elasticsearch
**Tags:** elastic-stack-alerting
**Created:** [November 7, 2016, 8:59pm UTC](https://discuss.elastic.co/t/setting-value-by-reading-from-a-file/65280 "2016-11-07T20:59:53Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![nielsoncr](https://avatars.discourse-cdn.com/v4/letter/n/c57346/32.png) [@nielsoncr](https://discuss.elastic.co/u/nielsoncr)
#### Post date: [November 7, 2016, 8:59pm UTC](https://discuss.elastic.co/t/setting-value-by-reading-from-a-file/65280/1 "2016-11-07T20:59:53Z")

</div>

I'm working on a couple dozen Watches that each execute a web hook action to call a RESTful service endpoint. This endpoint requires basic auth credentials to be passed that are currently built into the watch for prototyping. For a production deployment these credentials are will rotate on a regular basis. I don't want anyone to have to constantly modify each watch to keep up with rotating credentials, so my question is how can I get all of these watches to read these credentials from a common file and store them in a ctx.var that can be used in the web hook.

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: [November 8, 2016, 1:00pm UTC](https://discuss.elastic.co/t/setting-value-by-reading-from-a-file/65280/2 "2016-11-08T13:00:16Z")

</div>

Hey,

unfortunately there is currently no mechanism to support rotation of those passwords, except reindexing the watch (or using a chained input to get the auth from somewhere else, but that sounds not too secure either to be honest).

Maybe slightly helpful here: What watcher allows you to do however is to encrypt sensitive data, when shield is enabled. See [https://www.elastic.co/guide/en/watcher/2.4/shield-integration.html#shield-watch-data-encryption](https://www.elastic.co/guide/en/watcher/2.4/shield-integration.html#shield-watch-data-encryption)

The best solution to me feels like PKI based auth in order to prevent password rotation, but that of course depends on your setup.

--Alex

---

<div class="post-metadata">

### Author: ![nielsoncr](https://avatars.discourse-cdn.com/v4/letter/n/c57346/32.png) [@nielsoncr](https://discuss.elastic.co/u/nielsoncr)
#### Post date: [November 8, 2016, 4:02pm UTC](https://discuss.elastic.co/t/setting-value-by-reading-from-a-file/65280/3 "2016-11-08T16:02:31Z")

</div>

Alex -- Thank you for the suggestions. Unfortunately the Restful service being called only supports basic auth in its current configuration. Encrypting the sensitive data has been discussed as an option but that doesn't address a security/ops team's request to store credentials in a single location rather than in each watch.

---

<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 8, 2016, 4:19pm UTC](https://discuss.elastic.co/t/setting-value-by-reading-from-a-file/65280/4 "2016-11-08T16:19:40Z")

</div>

Hey,

you saw my suggestions with the chained input? You could store the credentials in another index (or another system that can be polled via HTTP), and only update those.

--Alex

---

<div class="post-metadata">

### Author: ![nielsoncr](https://avatars.discourse-cdn.com/v4/letter/n/c57346/32.png) [@nielsoncr](https://discuss.elastic.co/u/nielsoncr)
#### Post date: [November 8, 2016, 4:40pm UTC](https://discuss.elastic.co/t/setting-value-by-reading-from-a-file/65280/5 "2016-11-08T16:40:14Z")

</div>

Alex

I found this example to be helpful.

> [@Watcher chain input example, use case](https://discuss.elastic.co/t/watcher-chain-input-example-use-case/37688):
>
> Hi All, I am interested in evaluating watches from multiple inputs, as described in chain input approach on [watcher input ref]. ([https://www.elastic.co/guide/en/watcher/current/input.html#input-chain](https://www.elastic.co/guide/en/watcher/current/input.html#input-chain)). I am wondering if this is a valid scenario, or at least something that could be intended for by chain inputs: first input is a search input, second input is also a search input with parameters depending on ctx.payload.first.hits.hits.\_source Is this a valid approach on the current watcher…

Thanks

---

<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 6, 2016, 4:40pm UTC](https://discuss.elastic.co/t/setting-value-by-reading-from-a-file/65280/6 "2016-12-06T16:40:16Z")

</div>

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