# Will variables in ruby filter break with multiple workers?

**URL:** <https://discuss.elastic.co/t/will-variables-in-ruby-filter-break-with-multiple-workers/225285>\
**Category:** Logstash\
**Created:** [March 26, 2020, 8:26pm UTC](https://discuss.elastic.co/t/will-variables-in-ruby-filter-break-with-multiple-workers/225285 "2020-03-26T20:26:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![seanziee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/seanziee/32/45151_2.png) [@seanziee](https://discuss.elastic.co/u/seanziee)\
**Post date:** [March 26, 2020, 8:26pm UTC](https://discuss.elastic.co/t/will-variables-in-ruby-filter-break-with-multiple-workers/225285/1 "2020-03-26T20:26:53Z")

</div>

I'm using the ruby filter to clean up some data and during that cleanup, I create temporary variables and I have a few question on how variables may interfere with each other in a pipeline

Case)  
If I have multiple workers running simultaneously, will the local variables from a ruby filter in one worker ever interfere with another worker?

```auto
ruby {
  code => '
  a = event.get("field")
  event.set("b", a)
  '
}

```

If we imagine two logs going through logstash , one with `field:"foo`" and the other with `field:"bar"`, will the field `b` ever get switched by accident by logstash? Or does logstash separate the contexts of each worker so that a cross over could never occur?

---

<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:** [March 26, 2020, 8:42pm UTC](https://discuss.elastic.co/t/will-variables-in-ruby-filter-break-with-multiple-workers/225285/2 "2020-03-26T20:42:06Z")

</div>

> [@seanziee](#):
>
> will the field `b` ever get switched by accident by logstash?

No, not if you use a locally scoped variable name like 'a'. More details [here](https://discuss.elastic.co/t/multiple-pipelines-running-on-same-machine/225217/2).

---

<div class="post-metadata">

**Author:** ![seanziee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/seanziee/32/45151_2.png) [@seanziee](https://discuss.elastic.co/u/seanziee)\
**Post date:** [March 26, 2020, 10:19pm UTC](https://discuss.elastic.co/t/will-variables-in-ruby-filter-break-with-multiple-workers/225285/3 "2020-03-26T22:19:14Z")

</div>

Awesome 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:** [April 23, 2020, 10:19pm UTC](https://discuss.elastic.co/t/will-variables-in-ruby-filter-break-with-multiple-workers/225285/4 "2020-04-23T22:19:21Z")

</div>

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