# Add Gem to Logstash production

**URL:** <https://discuss.elastic.co/t/add-gem-to-logstash-production/92761>\
**Category:** Logstash\
**Created:** [July 12, 2017, 6:30am UTC](https://discuss.elastic.co/t/add-gem-to-logstash-production/92761 "2017-07-12T06:30:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kitz99](https://avatars.discourse-cdn.com/v4/letter/k/48db29/32.png) [@kitz99](https://discuss.elastic.co/u/kitz99)\
**Post date:** [July 12, 2017, 6:30am UTC](https://discuss.elastic.co/t/add-gem-to-logstash-production/92761/1 "2017-07-12T06:30:35Z")

</div>

Hello. I have installed a logstash 5.4 in a production env (RHEL 7) and now I need to add a new config, a new gem and some ruby classes to this logstash. Where I need to put my ruby code, and how can I install new gems?

I found logstash's Gemfile located in /usr/share/logstash. Is enough if I append my gem to this Gemfile and run bundle install using logstash's jruby?

Also, I have some Pure Ruby Objects that do some stuff and I call them from logstash config file using ruby filter, like this:

filter { ruby { code =\> "require 'ruby\_class'; RubyClass.new.call" } }

---

<div class="post-metadata">

**Author:** ![jakelandis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jakelandis/32/36163_2.png) [@jakelandis](https://discuss.elastic.co/u/jakelandis)\
**Post date:** [July 14, 2017, 2:58pm UTC](https://discuss.elastic.co/t/add-gem-to-logstash-production/92761/2 "2017-07-14T14:58:35Z")

</div>

I should start with a disclaimer that adding in gems directly is not formally supported.

If you need to do this, and you are comfortable with using bundler directly, The best approach may be to manage your gems with a different Gemfile and point bundler to the logstash\_home/vendor/bundle. (bundle install --path logstash\_home/vendor/bundle).

The problem with this approach is that your transitive dependencies may clash with Logstash. Alternatively if you add your dependency to the Gemfile of Logstash itself, it may work, but you have to ensure that the same .lock file is create, the install path is set correctly, and any updates will likely break this extra step.

It seems the least hacky (and supported) method would be to create a custom filter and install via the plug-in tooling.

---

<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:** [August 11, 2017, 2:58pm UTC](https://discuss.elastic.co/t/add-gem-to-logstash-production/92761/3 "2017-08-11T14:58:36Z")

</div>

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