How to add gems to Logstash
I am running Logstash 1.4.1, compared to the last one, I cannot find anywhere in my installation folders, contains information about gems (compared to the last code in github there are those gembag.rb, Gemfile, etc.)
My current problem: I need to use multiple gems that Logstash doesn't have in the box, just require 'gemname'
doesn't seem to work. Can anyone lead me to a read that explains how to add these third party gems or show me some sample codes that can do this.
Many thanks!
source to share
This is what worked for me in logstash 2.0.
env GEM_HOME=/opt/logstash/vendor/bundle/jruby/1.9 /opt/logstash/vendor/jruby/bin/jruby /opt/logstash/vendor/jruby/bin/gem install PACKAGE_NAME -v PACKAGE_VERSION
Then I had to edit /opt/logstash/Gemfile
to include the line:
gem "PACKAGE_NAME", "PACKAGE_VERSION"
I know that at some point we also executed yum install ruby-devel
, but I don't remember if this needs to work for this.
source to share
Logstash version independent script (can also be used for logstash 6.0.0):
env GEM_HOME=$$(echo /usr/share/logstash/vendor/bundle/jruby/*/) /opt/logstash/vendor/jruby/bin/jruby /opt/logstash/vendor/jruby/bin/gem install PACKAGE_NAME -v PACKAGE_VERSION
In fact, here is the complete script for installing the gem and adding the package metadata to the gem file:
env GEM_HOME=$$(echo /usr/share/logstash/vendor/bundle/jruby/*/) /opt/logstash/vendor/jruby/bin/jruby /opt/logstash/vendor/jruby/bin/gem install PACKAGE_NAME -v PACKAGE_VERSION
echo 'gem \"PACKAGE_NAME\", \"PACKAGE_VERSION\"' >> /usr/share/logstash/Gemfile
Logstash may change the version of JRuby in the future. For example, JRuby 2.3.0 is used in logstash 6.0.0. The above script does not require changing the JRuby version in the path when updating logstash.
source to share