Add Gem to Logstash production

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';" } }

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.

1 Like

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