Question: Logstash gives GemNotFound when running external ruby file from ruby filter plugin

Question

Logstash gives GemNotFound when running external ruby file from ruby filter plugin

Answers 0
Added at 2016-11-04 12:11
Tags
Question

I have a ruby file which I am trying to run in ruby script of ruby filter plugin.

This is my ruby script in logstash.conf file:

input {
    file {
       path => "C:/ELK Stack/logstash-5.0.0/data/Encrypt.log"
       start_position => "beginning"
       sincedb_path => "../bulk.sincedb"
       ignore_older => 0 
   }
}

filter {
    ruby{
        code => 'require "open3"
                msg = event.get("[message]")
                cmd =  "jruby DecryptRuby.rb " + msg
                stdin, stdout, stderr = Open3.popen3(cmd)
                puts "Decrypted as " + stdout.read + stderr.read
                event.set("[decrypted_msg]", stdout.read)'
    }
}

output {
    stdout {
        codec => rubydebug
   }
}

The ruby file looks something like this:

require 'java'
require 'DecryptPBE.jar'
import 'decrypt.DecryptPBEwithMD5AndDES'

decryptObj = Java::Decrypt::DecryptPBEwithMD5AndDES.decryptData(ARGV[0],'somekey1');
puts decryptObj;

This ruby file works fine when run from jruby console. But when I tried to run from the above logstash.conf configuration it gives the error on the logstash console as:

[2016-11-04T14:58:07,364][DEBUG][logstash.pipeline        ] filter received {"event"=>{"path"=>"C:/ELK Stack/logstash-5
.0.0/data/Encrypt.log", "@timestamp"=>2016-11-04T09:28:06.524Z, @version"=>"1", "host"=>"HostABC", "message"=>"K+q6vq
wgqTId+zY7vM3S5zieno1IEblu\r"}}
2016-11-04 14:58:09 +0530}
[2016-11-04T14:58:10,822][DEBUG][logstash.instrument.collector] Collector: Sending snapshot to observers {:created_at=>
2016-11-04 14:58:10 +0530}
[2016-11-04T14:58:11,452][DEBUG][logstash.pipeline        ] Pushing flush onto pipeline
Decrypted as Bundler::GemNotFound: Could not find gem 'ci_reporter_rspec (= 1.0.0) java' in any of the gem sources list
ed in your Gemfile or installed on this machine.
  verify_gemfile_dependencies_are_found! at C:/ELK Stack/logstash-5.0.0/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/resolver.rb:328
                                    each at org/jruby/RubyArray.java:1613
  verify_gemfile_dependencies_are_found! at C:/ELK Stack/logstash-5.0.0/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/resolver.rb:307
                                   start at C:/ELK Stack/logstash-5.0.0/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/resolver.rb:199
                                 resolve at C:/ELK Stack/logstash-5.0.0/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/resolver.rb:182
                                 resolve at C:/ELK Stack/logstash-5.0.0/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/definition.rb:192
                                   specs at C:/ELK Stack/logstash-5.0.0/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/definition.rb:132
                               specs_for at C:/ELK Stack/logstash-5.0.0/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/definition.rb:177
                         requested_specs at C:/ELK Stack/logstash-5.0.0/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/definition.rb:166
                         requested_specs at C:/ELK Stack/logstash-5.0.0/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/environment.rb:18
                                   setup at C:/ELK Stack/logstash-5.0.0/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/runtime.rb:13
                                   setup at C:/ELK Stack/logstash-5.0.0/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler.rb:122
                                  (root) at C:/ELK Stack/logstash-5.0.0/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/setup.rb:18
                                 require at org/jruby/RubyKernel.java:1040
                                  (root) at C:/ELK Stack/logstash-5.0.0/vendor/jruby/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
[2016-11-04T14:58:11,502][DEBUG][logstash.pipeline        ] 
filter received {"event"=>{"path"=>"C:/ELK Stack/logstash-5.0.0/data/Encrypt.log", "@timestamp"=>2016-11-04T09:28:06.527Z, "@version"=>"1", "host"=>"D9ZHR9B2", "message"=>"K+q6vq  wgqTId+zY7vM3S5zieno1IEblu\r"}}
[2016-11-04T14:58:15,441][DEBUG][logstash.pipeline        ] output received {"event"=>{"path"=>"C:/ELK Stack/logstash-5.0.0/data/Encrypt.log", "@timestamp"=>2016-11-04T09:28:06.527Z, "@version"=>"1", "host"=>"D9ZHR9B2", "message"=>"K+q6vqwgqTId+zY7vM3S5zieno1IEblu\r", "decrypted_msg"=>""}}
{
             "path" => "C:/ELK Stack/logstash-5.0.0/data/Encrypt.log",
       "@timestamp" => 2016-11-04T09:28:06.524Z,
         "@version" => "1",
             "host" => "D9ZHR9B2",
          "message" => "K+q6vqwgqTId+zY7vM3S5zieno1IEblu\r",
    "decrypted_msg" => ""
}

What I am able to deduce from this log is that ci_reporter_rspec gem is missing. Tried to search this gem but couldn't find anything with that name. So I tried to install it with the command,

gem install ci_reporter_rspec

It installed successfully. But this didn't resolve the issue I am still getting the same error message in the console.

Can't make out what I have missed on this. I am using logstash-5.0.0. Any help or suggestion will be much appreciated.

Thanks.

Answers to

Logstash gives GemNotFound when running external ruby file from ruby filter plugin

Source Show
◀ Wstecz