# Strict execution ordering of Logstash output plugins

**URL:** https://discuss.elastic.co/t/strict-execution-ordering-of-logstash-output-plugins/317048
**Category:** Logstash
**Created:** [October 19, 2022, 8:29pm UTC](https://discuss.elastic.co/t/strict-execution-ordering-of-logstash-output-plugins/317048 "2022-10-19T20:29:28Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![gordonjlee](https://avatars.discourse-cdn.com/v4/letter/g/858c86/32.png) [@gordonjlee](https://discuss.elastic.co/u/gordonjlee)
#### Post date: [October 19, 2022, 8:29pm UTC](https://discuss.elastic.co/t/strict-execution-ordering-of-logstash-output-plugins/317048/1 "2022-10-19T20:29:28Z")

</div>

I have 2 outputs from a Logstash instance, one output to Elasticsearch and one output to a Kafka topic that is consumed by a homegrown ms. In practice, I have seen instances where the ms consuming the Kafka topic receives a record before it was completely committed to Elasticsearch, and a search fails.

I would like to enforce the requirement that the output to Elasticsearch is fully complete and committed before sending to the Kafka topic. How can I do this?

Thanks

---

<div class="post-metadata">

### Author: ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)
#### Post date: [October 19, 2022, 8:34pm UTC](https://discuss.elastic.co/t/strict-execution-ordering-of-logstash-output-plugins/317048/2 "2022-10-19T20:34:27Z")

</div>

pipeline.workers - This defaults to the number of the host's CPU cores.

I think this should solve the issue:  
`pipeline.workers : 1`

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [October 19, 2022, 9:55pm UTC](https://discuss.elastic.co/t/strict-execution-ordering-of-logstash-output-plugins/317048/3 "2022-10-19T21:55:43Z")

</div>

You have no control over the order in which outputs process events. Once the batch gets to the end of the pipeline it gets sent to the outputs for them to process at their leisure.

You could send data to the kafka output viâ a separate pipeline with a sleep filter in it, but that does not provide very fine control, and still does not guarantee the result you want.

---

<div class="post-metadata">

### Author: ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)
#### Post date: [October 20, 2022, 4:50am UTC](https://discuss.elastic.co/t/strict-execution-ordering-of-logstash-output-plugins/317048/4 "2022-10-20T04:50:43Z")

</div>

Badger, shouldn't a single process do execution from input to output, line by line?  
Does parallelism makes mix data processing, out of order?

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [October 20, 2022, 3:29pm UTC](https://discuss.elastic.co/t/strict-execution-ordering-of-logstash-output-plugins/317048/5 "2022-10-20T15:29:40Z")

</div>

As far as I know input threads and output threads are independent of the pipeline. Setting pipeline.workers to 1 and pipeline.ordered to true will make sure that events are kept in order within the filters, but I have never seen anything that suggests either inputs or outputs use any synchronization between threads.

pipeline.ordered had to be added because re-ordering events within the pipeline broke documented behaviour of the aggregate plugin. I do not think there is any documentation about how threads in the inputs and outputs behave.

---

<div class="post-metadata">

### Author: ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)
#### Post date: [October 20, 2022, 10:49pm UTC](https://discuss.elastic.co/t/strict-execution-ordering-of-logstash-output-plugins/317048/6 "2022-10-20T22:49:13Z")

</div>

I already had similar problem, explained on this [topic](https://discuss.elastic.co/t/file-mirroring-via-filebeat-or-logstash/315973/3). Only set `pipeline.workers: 1` , not extra set pipeline.ordered, so it's "auto".  
It's just matter how to output push data in the same order as receive in input.  
I1,I2,I3 =\> O1,O2,O3

---

<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 17, 2022, 10:50pm UTC](https://discuss.elastic.co/t/strict-execution-ordering-of-logstash-output-plugins/317048/7 "2022-11-17T22:50:07Z")

</div>

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