# Sequence Number Generation

**URL:** <https://discuss.elastic.co/t/sequence-number-generation/358563>\
**Category:** Logstash\
**Created:** [May 1, 2024, 1:07pm UTC](https://discuss.elastic.co/t/sequence-number-generation/358563 "2024-05-01T13:07:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dawiro](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@dawiro](https://discuss.elastic.co/u/dawiro)\
**Post date:** [May 1, 2024, 1:07pm UTC](https://discuss.elastic.co/t/sequence-number-generation/358563/1 "2024-05-01T13:07:32Z")

</div>

We would like to annotate our inbound log messages with sequence numbers which we can then use to detect and measure message loss.

What is the best way to go about this? Use in-line ruby code to generate sequence numbers or an external generator, like redis? And might an external generator have a noticeable impact on throughput?

Thx  
D

---

<div class="post-metadata">

**Author:** ![dawiro](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@dawiro](https://discuss.elastic.co/u/dawiro)\
**Post date:** [May 9, 2024, 1:08pm UTC](https://discuss.elastic.co/t/sequence-number-generation/358563/2 "2024-05-09T13:08:02Z")

</div>

Has noone crossed this particular bridge before?

---

<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:** [May 9, 2024, 2:30pm UTC](https://discuss.elastic.co/t/sequence-number-generation/358563/3 "2024-05-09T14:30:22Z")

</div>

> [@dawiro](#):
>
> Use in-line ruby code to generate sequence numbers or an external generator, like redis?

If you use ruby then you will need to make sure that pipeline.workers is set to 1 and pipeline.ordered evaluates to true. That limits throughput.

I cannot speak to solutions external to logstash.

---

<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:** [May 9, 2024, 2:39pm UTC](https://discuss.elastic.co/t/sequence-number-generation/358563/4 "2024-05-09T14:39:13Z")

</div>

If you want to measure message losses, you can use the [pipeline statistic](https://www.elastic.co/guide/en/logstash/current/node-stats-api.html#pipeline-stats). Have you tried monitoring Logstash or ELK stack with Metricbeat or ElasticAgent?
