# Ruby Code out of Logstash Pipeline

**URL:** <https://discuss.elastic.co/t/ruby-code-out-of-logstash-pipeline/171743>\
**Category:** Logstash\
**Created:** [March 11, 2019, 11:38am UTC](https://discuss.elastic.co/t/ruby-code-out-of-logstash-pipeline/171743 "2019-03-11T11:38:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael.Swiss](https://avatars.discourse-cdn.com/v4/letter/m/c5a1d2/32.png) [@Michael.Swiss](https://discuss.elastic.co/u/Michael.Swiss)\
**Post date:** [March 11, 2019, 11:38am UTC](https://discuss.elastic.co/t/ruby-code-out-of-logstash-pipeline/171743/1 "2019-03-11T11:38:01Z")

</div>

Dear all

I am building a filter plugin that calls a ruby .rb code file. The filter itself is well documented.  
The issues I have is with ruby gems and the transmission of variables:

The documentation says that ruby gems don't work. I however need to include "nokogiri" in the .rb file for crawling a website. When will this feature be possible? - see below.

I also need to transfer variables from logstash to .rb ("script\_params" I assume). And then from .rb back to the logstash pipeline - how does this work?

Best Michael

Source: [https://www.elastic.co/de/blog/moving-ruby-code-out-of-logstash-pipeline](https://www.elastic.co/de/blog/moving-ruby-code-out-of-logstash-pipeline)

"#### Limitations

Even though file-based scripting in the ruby filter provides code reuse and testability, there are stillÂ limitationsÂ compared to full blown Logstash plugins. The main one is lack of support for third-party libraries: if you need the custom ruby code to use a library that doesn't ship with Logstash, it's not possible to load it through the ruby filter."

---

<div class="post-metadata">

**Author:** ![yaauie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yaauie/32/23363_2.png) [@yaauie](https://discuss.elastic.co/u/yaauie)\
**Post date:** [March 12, 2019, 1:08am UTC](https://discuss.elastic.co/t/ruby-code-out-of-logstash-pipeline/171743/2 "2019-03-12T01:08:17Z")

</div>

> [@Michael.Swiss](#):
>
> I however need to include "nokogiri" in the .rb file for crawling a website. When will this feature be possible?

This is not currently possible, and is not a feature that is planned to be added.

> [@Michael.Swiss](#):
>
> I also need to transfer variables from logstash to .rb ("script\_params" I assume). And then from .rb back to the logstash pipeline - how does this work?

The ruby script can provide a `register` method that takes a key/value hash as input, and sets instance variables that can be used when the `filter(event)` is invoked.

I have a small collection of such scripts [here](https://gist.github.com/yaauie/4ec8123a680dc2532f36b5b393ff11a7#file-transpose-logstash-filter-ruby-rb-L27) that can be used as examples.

---

<div class="post-metadata">

**Author:** ![Michael.Swiss](https://avatars.discourse-cdn.com/v4/letter/m/c5a1d2/32.png) [@Michael.Swiss](https://discuss.elastic.co/u/Michael.Swiss)\
**Post date:** [March 12, 2019, 7:22am UTC](https://discuss.elastic.co/t/ruby-code-out-of-logstash-pipeline/171743/3 "2019-03-12T07:22:21Z")

</div>

> [@yaauie](#):
>
> key/value hash as

Dear yaauie

Thanks. I guess I need to split up the single intended logstash pipeline into multiple processes with some of them running on ruby native code.

Michael

---

<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 9, 2019, 7:22am UTC](https://discuss.elastic.co/t/ruby-code-out-of-logstash-pipeline/171743/4 "2019-04-09T07:22:23Z")

</div>

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