Logstash pozwala executing arbitrary commands jako dane wejściowe dla potoku. Oto mój przykład rurociąg:Wykonaj ruby jako dane wejściowe potoku do logstash
input {
exec {
command => '/usr/bin/ruby -e "puts RUBY_VERSION"'
interval => 10
}
}
output {
stdout { codec => rubydebug }
}
Dzięki temu pojawia się następujący błąd:
/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'
Próbowałem też działa logstash za własny JRuby wewnątrz Exec jak ten
input {
exec {
command => '/opt/logstash/vendor/jruby/bin/jruby -e "puts RUBY_VERSION"'
interval => 10
}
}
output {
stdout { codec => rubydebug }
}
i tworzy kolejny błąd programu 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 działa, a potok jest uruchamiany co 10 sekund, ale komunikat jest zawsze pusty. Próba wykonania innych poleceń, takich jak echo "hello"
, działa bezproblemowo.
Działa na logstash 2.4.0, wersja openjdk "1.8.0_102", rubin systemowy to MRI 2.3.1 na Archlinux ARM.
Wszelkie pomysły?
Czy próbowałeś uruchomić 'bundle install'? –
yes, logstash jest poprawnie zainstalowany, działa, gdy nie próbuję uruchamiać komend ruby – ben
Czy masz plik wykonywalny 'bundle' w katalogu'/opt/logstash/vendor/jruby/bin'? Wolałbym raczej użyć własnej instalacji, zamiast pakietu logstash, jeśli zamierzasz używać bibliotek ruby. –