# Persist data between log lines with ruby filter

**URL:** <https://discuss.elastic.co/t/persist-data-between-log-lines-with-ruby-filter/206068>\
**Category:** Logstash\
**Created:** [October 31, 2019, 3:06pm UTC](https://discuss.elastic.co/t/persist-data-between-log-lines-with-ruby-filter/206068 "2019-10-31T15:06:13Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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 31, 2019, 5:15pm UTC](https://discuss.elastic.co/t/persist-data-between-log-lines-with-ruby-filter/206068/2 "2019-10-31T17:15:30Z")

</div>

> [@jong99](#):
>
> I'd rather not use global variables unless absolutely necessary.

You should never need to use global variables. You can do this using an instance variable (@last\_event). You can only use a single worker thread, so the solution does not scale, and you have to use the ruby execution engine because with java\_execution enabled events get [re-ordered](https://github.com/elastic/logstash/issues/10938).

---

_[View the full topic](https://discuss.elastic.co/t/persist-data-between-log-lines-with-ruby-filter/206068)._
