# What is the execution sequence of watcher actions?

**URL:** <https://discuss.elastic.co/t/what-is-the-execution-sequence-of-watcher-actions/105129>\
**Category:** Elasticsearch\
**Created:** [October 24, 2017, 9:51pm UTC](https://discuss.elastic.co/t/what-is-the-execution-sequence-of-watcher-actions/105129 "2017-10-24T21:51:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![naziyakhan](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@naziyakhan](https://discuss.elastic.co/u/naziyakhan)\
**Post date:** [October 24, 2017, 9:51pm UTC](https://discuss.elastic.co/t/what-is-the-execution-sequence-of-watcher-actions/105129/1 "2017-10-24T21:51:50Z")

</div>

Are the actions synchronous or asynchronous?  
Are they sequential?

I would like to use the output of the first action written to watcher-history in the second action of the watcher? Is this possible and / or recommended?

---

<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:** [October 24, 2017, 10:30pm UTC](https://discuss.elastic.co/t/what-is-the-execution-sequence-of-watcher-actions/105129/2 "2017-10-24T22:30:28Z")

</div>

they are sequential and independent from each other. You cannot access any data from one action in another. Depending on your JSON serializer when writing the JSON to Elasticsearch the order is not guaranteed, this would require an array in JSON.

--Alex

---

<div class="post-metadata">

**Author:** ![naziyakhan](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@naziyakhan](https://discuss.elastic.co/u/naziyakhan)\
**Post date:** [October 24, 2017, 10:45pm UTC](https://discuss.elastic.co/t/what-is-the-execution-sequence-of-watcher-actions/105129/3 "2017-10-24T22:45:54Z")

</div>

You mean to say the actions are executed in the order in which they appear in the watcher's definition right?  
As long as, we ensure that they are in the correct order, we could use the results of action 1 written in watcher history in action 2?

---

<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:** [October 25, 2017, 7:01am UTC](https://discuss.elastic.co/t/what-is-the-execution-sequence-of-watcher-actions/105129/4 "2017-10-25T07:01:28Z")

</div>

You cant. That was what I meant with their are independent from each other. No action can enrich the payload or change the context, thus you cannot access any result of an action.

You might be able to achieve something similar with a chained input, but that highly depends on your use-case, which you have not revealed yet.

Another alternative is always to run two watches of course.

---

<div class="post-metadata">

**Author:** ![naziyakhan](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@naziyakhan](https://discuss.elastic.co/u/naziyakhan)\
**Post date:** [October 25, 2017, 5:04pm UTC](https://discuss.elastic.co/t/what-is-the-execution-sequence-of-watcher-actions/105129/5 "2017-10-25T17:04:48Z")

</div>

Thanks Alexander!

---

<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:** [November 22, 2017, 5:04pm UTC](https://discuss.elastic.co/t/what-is-the-execution-sequence-of-watcher-actions/105129/6 "2017-11-22T17:04:50Z")

</div>

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