Logstash允许executing arbitrary commands作为管道的输入。 这是我的示例管道:
input {
exec {
command => '/usr/bin/ruby -e "puts RUBY_VERSION"'
interval => 10
}
}
output {
stdout { codec => rubydebug }
}
有了这个,我收到以下错误:
/opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/resolver.rb:328:in `block in verify_gemfile_dependencies_are_found!': Could not find gem 'logstash-core (= 2.4.0) ruby' in any of the gem sources listed in your Gemfile or installed on this machine. (Bundler::GemNotFound)
from /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/resolver.rb:307:in `each'
from /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/resolver.rb:307:in `verify_gemfile_dependencies_are_found!'
from /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/resolver.rb:199:in `start'
from /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/resolver.rb:182:in `resolve'
from /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/definition.rb:192:in `resolve'
from /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/definition.rb:132:in `specs'
from /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/definition.rb:177:in `specs_for'
from /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/definition.rb:166:in `requested_specs'
from /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/environment.rb:18:in `requested_specs'
from /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/runtime.rb:13:in `setup'
from /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler.rb:122:in `setup'
from /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/setup.rb:18:in `<top (required)>'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
我也试过像这样在exec中运行logstash自己的JRuby
input {
exec {
command => '/opt/logstash/vendor/jruby/bin/jruby -e "puts RUBY_VERSION"'
interval => 10
}
}
output {
stdout { codec => rubydebug }
}
它会创建另一个Bundler错误:
Bundler::GemNotFound: Could not find gem 'ci_reporter_rspec (= 1.0.0) java' in any of the gem sources listed in your Gemfile or installed on this machine.
verify_gemfile_dependencies_are_found! at /opt/logstash/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 /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/resolver.rb:307
start at /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/resolver.rb:199
resolve at /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/resolver.rb:182
resolve at /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/definition.rb:192
specs at /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/definition.rb:132
specs_for at /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/definition.rb:177
requested_specs at /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/definition.rb:166
requested_specs at /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/environment.rb:18
setup at /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/runtime.rb:13
setup at /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler.rb:122
(root) at /opt/logstash/vendor/bundle/jruby/1.9/gems/bundler-1.9.10/lib/bundler/setup.rb:18
require at org/jruby/RubyKernel.java:1040
(root) at /opt/logstash/vendor/jruby/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
Logstash继续运行,管道每10秒执行一次,但消息始终为空。尝试执行echo "hello"
之类的其他命令可以顺利运行。
在logstash 2.4.0,openjdk版本&#34; 1.8.0_102&#34;上运行,系统ruby是Archlinux ARM上的MRI 2.3.1。
有什么想法吗?
答案 0 :(得分:2)
看起来您可能需要切换到JRuby而不是MRI,这对于Logstash而不是currently supported是实验性的。您可以考虑RVM或rbenv来帮助管理不同的Ruby版本,并根据需要在shell中切换JRuby和native。
使用JRuby + bundler(gem install bundler
)之后,您可以从项目根目录bundle install
解决您的依赖性问题。