From: https://discuss.elastic.co/t/custom-plugin-not-found/79565
Im working this plugin to fetch logs from hdfs, this is the gemspec file:
s.name = 'logstash-input-webhdfs'
s.version = '0.1.0'
s.licenses = ['Apache License (2.0)']
s.summary = 'Write a short summary, because Rubygems requires one.'
s.description = 'Write a longer description or delete this line.'
s.homepage = 'http://localhost'
s.authors = ['xxxxxxx']
s.email = '[email protected]'
s.require_paths = ['lib']
# Files
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
# Tests
s.test_files = s.files.grep(%r{^(test|spec|features)/})
# Special flag to let us know this is actually a logstash plugin
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
# Gem dependencies
s.add_runtime_dependency 'logstash-core'
s.add_runtime_dependency "logstash-core-plugin-api"
s.add_runtime_dependency 'webhdfs'
s.add_development_dependency 'logstash-devutils'
s.add_development_dependency 'logstash-codec-line'
I create the gem file using gem build, then I install it with logstash-plugin install commad.
finally I check if the plugin is installed witth logstash-plugin list command.
When launching logstash this error popup :
[2017-03-22T11:15:41,977][ERROR][logstash.plugins.registry] Problems loading a plugin with {:type=>"input", :name=>"webhdfs", :path=>"logstash/inputs/webhdfs", :error_message=>"NameError", :error_class=>NameError, :error_backtrace=>["/opt/logstash-5.2.2/logstash-core/lib/logstash/plugins/registry.rb:221:in `namespace_lookup'", "/opt/logstash-5.2.2/logstash-core/lib/logstash/plugins/registry.rb:157:in `legacy_lookup'", "/opt/logstash-5.2.2/logstash-core/lib/logstash/plugins/registry.rb:133:in `lookup'", "/opt/logstash-5.2.2/logstash-core/lib/logstash/plugins/registry.rb:175:in `lookup_pipeline_plugin'", "/opt/logstash-5.2.2/logstash-core/lib/logstash/plugin.rb:129:in `lookup'", "/opt/logstash-5.2.2/logstash-core/lib/logstash/pipeline.rb:95:in `plugin'", "(eval):12:in `initialize'", "org/jruby/RubyKernel.java:1079:in `eval'", "/opt/logstash-5.2.2/logstash-core/lib/logstash/pipeline.rb:65:in `initialize'", "/opt/logstash-5.2.2/logstash-core/lib/logstash/pipeline.rb:144:in `initialize'", "/opt/logstash-5.2.2/logstash-core/lib/logstash/agent.rb:275:in `create_pipeline'", "/opt/logstash-5.2.2/logstash-core/lib/logstash/agent.rb:95:in `register_pipeline'", "/opt/logstash-5.2.2/logstash-core/lib/logstash/runner.rb:264:in `execute'", "/opt/logstash-5.2.2/vendor/bundle/jruby/1.9/gems/clamp-0.6.5/lib/clamp/command.rb:67:in `run'", "/opt/logstash-5.2.2/logstash-core/lib/logstash/runner.rb:183:in `run'", "/opt/logstash-5.2.2/vendor/bundle/jruby/1.9/gems/clamp-0.6.5/lib/clamp/command.rb:132:in `run'", "/opt/logstash-5.2.2/lib/bootstrap/environment.rb:71:in `(root)'"]}
[2017-03-22T11:15:41,979][DEBUG][logstash.plugins.registry] Problems loading the plugin with {:type=>"input", :name=>"webhdfs"}
[2017-03-22T11:15:41,985][ERROR][logstash.agent ] Cannot load an invalid configuration {:reason=>"Couldn't find any input plugin named 'webhdfs'. Are you sure this is correct? Trying to load the webhdfs input plugin resulted in this error: Problems loading the requested plugin named webhdfs of type input. Error: NameError NameError", :backtrace=>["/opt/logstash-5.2.2/logstash-core/lib/logstash/plugins/registry.rb:180:in `lookup_pipeline_plugin'", "/opt/logstash-5.2.2/logstash-core/lib/logstash/plugin.rb:129:in `lookup'", "/opt/logstash-5.2.2/logstash-core/lib/logstash/pipeline.rb:95:in `plugin'", "(eval):12:in `initialize'", "org/jruby/RubyKernel.java:1079:in `eval'", "/opt/logstash-5.2.2/logstash-core/lib/logstash/pipeline.rb:65:in `initialize'", "/opt/logstash-5.2.2/logstash-core/lib/logstash/pipeline.rb:144:in `initialize'", "/opt/logstash-5.2.2/logstash-core/lib/logstash/agent.rb:275:in `create_pipeline'", "/opt/logstash-5.2.2/logstash-core/lib/logstash/agent.rb:95:in `register_pipeline'", "/opt/logstash-5.2.2/logstash-core/lib/logstash/runner.rb:264:in `execute'", "/opt/logstash-5.2.2/vendor/bundle/jruby/1.9/gems/clamp-0.6.5/lib/clamp/command.rb:67:in `run'", "/opt/logstash-5.2.2/logstash-core/lib/logstash/runner.rb:183:in `run'", "/opt/logstash-5.2.2/vendor/bundle/jruby/1.9/gems/clamp-0.6.5/lib/clamp/command.rb:132:in `run'", "/opt/logstash-5.2.2/lib/bootstrap/environment.rb:71:in `(root)'"]}
The plugin is well listed, I tried to remove/install the plugin but i don't untersatand the resons.
Last, my logstash (5.2.2) is not running as a service.
Could you please help me to solve this. Tank you.
For all general issues, please provide the following details for fast resolution:
Can you include or link the content of your plugin ruby file?
I'm having the same problem I made a post here discuss elastic with all the details
I had the same problem when I was testing my plugin. The 'NameError' message is indistinct and confusing.
I read the plugin loading part of logstash code and found that 'LoadError' exception is omitted when there are problems importing the plugin(it locates in the #legacy_lookup method in registry.rb). So I suggest log this 'LoadError' message to make problems clear. @ph
Same problem encountered trying to install the logstash-input-journald plugin.
Also made a post on discuss elastic with relevant details.
@daplho I cannot reproduce this. It works fine for me -
% bin/logstash-plugin install logstash-input-journald
Validating logstash-input-journald
Installing logstash-input-journald
Installation successful
% bin/logstash -e 'input { journald { } }'
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
Sending Logstash's logs to /home/jls/build/logstash-5.5.0/logs which is now configured via log4j2.properties
[2017-09-05T14:01:21,698][INFO ][logstash.pipeline ] Starting pipeline {"id"=>"main", "pipeline.workers"=>4, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>5, "pipeline.max_inflight"=>500}
[2017-09-05T14:01:21,719][INFO ][logstash.inputs.journald ] No sincedb_path set, generating one for the journal {:sincedb_path=>"/home/jls/build/logstash-5.5.0/.sincedb_journal"}
[2017-09-05T14:01:21,723][INFO ][logstash.pipeline ] Pipeline main started
[2017-09-05T14:01:21,766][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600}
@daplho your problem is unlikely the same as this issue. I replied on your discuss issue.
Printing the exception from legacy_lookup in registry.rb @jordansissel thx
rescue LoadError => e
puts e
puts e.backtrace
end
Reveals that in the journald input case where I can repro the problem, is due to the platform I am on not having systemd libraries (mac):
Could not open library 'libsystemd.so.0' : dlopen(libsystemd.so.0, 5): image not found. Could not open library 'libsystemd.so.0.dylib' : dlopen(libsystemd.so.0.dylib, 5): image not found. Could not open library 'libsystemd.so' : dlopen(libsystemd.so, 5): image not found. Could not open library 'libsystemd.so.dylib' : dlopen(libsystemd.so.dylib, 5): image not found. Could not open library 'libsystemd-id128.so.0' : dlopen(libsystemd-id128.so.0, 5): image not found. Could not open library 'libsystemd-id128.so.0.dylib' : dlopen(libsystemd-id128.so.0.dylib, 5): image not found. Could not open library 'libsystemd-id128.so' : dlopen(libsystemd-id128.so, 5): image not found. Could not open library 'libsystemd-id128.so.dylib' : dlopen(libsystemd-id128.so.dylib, 5): image not found
/private/tmp/logstash-5.5.0/vendor/jruby/lib/ruby/shared/ffi/library.rb:114:in `ffi_lib'
org/jruby/RubyArray.java:2414:in `map'
/private/tmp/logstash-5.5.0/vendor/jruby/lib/ruby/shared/ffi/library.rb:84:in `ffi_lib'
/tmp/logstash-5.5.0/vendor/bundle/jruby/1.9/gems/systemd-journal-1.2.3/lib/systemd/id128.rb:48:in `Native'
/tmp/logstash-5.5.0/vendor/bundle/jruby/1.9/gems/systemd-journal-1.2.3/lib/systemd/id128.rb:45:in `Id128'
/tmp/logstash-5.5.0/vendor/bundle/jruby/1.9/gems/systemd-journal-1.2.3/lib/systemd/id128.rb:6:in `Systemd'
/tmp/logstash-5.5.0/vendor/bundle/jruby/1.9/gems/systemd-journal-1.2.3/lib/systemd/id128.rb:3:in `(root)'
org/jruby/RubyKernel.java:1040:in `require'
/tmp/logstash-5.5.0/vendor/bundle/jruby/1.9/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
/tmp/logstash-5.5.0/vendor/bundle/jruby/1.9/gems/systemd-journal-1.2.3/lib/systemd/journal/native.rb:1:in `(root)'
org/jruby/RubyKernel.java:1040:in `require'
/tmp/logstash-5.5.0/vendor/bundle/jruby/1.9/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
/tmp/logstash-5.5.0/vendor/bundle/jruby/1.9/gems/systemd-journal-1.2.3/lib/systemd/journal/native.rb:1:in `(root)'
org/jruby/RubyKernel.java:1040:in `require'
/tmp/logstash-5.5.0/vendor/bundle/jruby/1.9/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
/tmp/logstash-5.5.0/vendor/bundle/jruby/1.9/gems/systemd-journal-1.2.3/lib/systemd/journal.rb:1:in `(root)'
org/jruby/RubyKernel.java:1040:in `require'
/tmp/logstash-5.5.0/vendor/bundle/jruby/1.9/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
/tmp/logstash-5.5.0/vendor/bundle/jruby/1.9/gems/systemd-journal-1.2.3/lib/systemd/journal.rb:2:in `(root)'
/tmp/logstash-5.5.0/vendor/local_gems/203dea6e/logstash-input-journald-2.0.1/lib/logstash/inputs/journald.rb:1:in `(root)'
/tmp/logstash-5.5.0/vendor/local_gems/203dea6e/logstash-input-journald-2.0.1/lib/logstash/inputs/journald.rb:5:in `(root)'
/tmp/logstash-5.5.0/logstash-core/lib/logstash/plugins/registry.rb:1:in `(root)'
/tmp/logstash-5.5.0/logstash-core/lib/logstash/plugins/registry.rb:156:in `legacy_lookup'
/tmp/logstash-5.5.0/logstash-core/lib/logstash/plugins/registry.rb:138:in `lookup'
org/jruby/RubyKernel.java:1079:in `eval'
/tmp/logstash-5.5.0/logstash-core/lib/logstash/plugins/registry.rb:185:in `lookup_pipeline_plugin'
/tmp/logstash-5.5.0/logstash-core/lib/logstash/plugin.rb:140:in `lookup'
/tmp/logstash-5.5.0/logstash-core/lib/logstash/pipeline.rb:100:in `plugin'
(eval):8:in `initialize'
/tmp/logstash-5.5.0/logstash-core/lib/logstash/pipeline.rb:72:in `initialize'
/tmp/logstash-5.5.0/lib/bootstrap/environment.rb:71:in `(root)'
The issue with this particular plugin (journald) is that we intended runtime code loading to occur in the _register_ method and not at the time the plugin is read from disk. Because this plugin does not do that, it will fail on every platform where the systemd-journal library fails to initialize on startup.
You are correct @ppf2. I thought that because I'm running these in docker containers I will be impervious to mac issues but I just tested this together with my coworker on her Ubuntu 16.04 and journald is available.
Cheers!
Super, thx for the tip and for the PR to improve the logging! 鉂わ笍 @jordansissel
@jordansissel , thanks for the commit for improving the log.
But I would like to know the possible reason for this LogStash::PluginLoadingError exception if I installed successfully the plugin (I can see the plugin with bin/logstash-plugin list --verbose with the right version).
ERROR MESSAGE:
:message=>"Couldn't find any output plugin named 'azure'. Are you sure this is correct? Trying to load the azure output plugin resulted in this error: no such file to load -- logstash/outputs/azure",
BACKTRACE:
:backtrace=>["/home/bruno/workspace/logstash/logstash-core/lib/logstash/plugins/registry.rb:192:in lookup_pipeline_plugin'", "/home/bruno/workspace/logstash/logstash-core/lib/logstash/plugin.rb:140:in lookup'", "/home/bruno/workspace/logstash/logstash-core/lib/logstash/pipeline.rb:143:in plugin'", "(eval):12:in <eval>'", "org/jruby/RubyKernel.java:994:in eval'", "/home/bruno/workspace/logstash/logstash-core/lib/logstash/pipeline.rb:82:in initialize'", "/home/bruno/workspace/logstash/logstash-core/lib/logstash/pipeline.rb:215:in initialize'", "/home/bruno/workspace/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:35:in execute'", "/home/bruno/workspace/logstash/logstash-core/lib/logstash/agent.rb:335:in block in converge_state'", "/home/bruno/workspace/logstash/logstash-core/lib/logstash/agent.rb:141:in with_pipelines'", "/home/bruno/workspace/logstash/logstash-core/lib/logstash/agent.rb:332:in block in converge_state'", "org/jruby/RubyArray.java:1734:in each'", "/home/bruno/workspace/logstash/logstash-core/lib/logstash/agent.rb:319:in converge_state'", "/home/bruno/workspace/logstash/logstash-core/lib/logstash/agent.rb:166:in block in converge_state_and_update'", "/home/bruno/workspace/logstash/logstash-core/lib/logstash/agent.rb:141:in with_pipelines'", "/home/bruno/workspace/logstash/logstash-core/lib/logstash/agent.rb:164:in converge_state_and_update'", "/home/bruno/workspace/logstash/logstash-core/lib/logstash/agent.rb:90:in execute'", "/home/bruno/workspace/logstash/logstash-core/lib/logstash/runner.rb:362:in block in execute'", "/home/bruno/workspace/logstash/vendor/bundle/jruby/2.3.0/gems/stud-0.0.23/lib/stud/task.rb:24:in block in initialize'"]
This is the conf file. Is there something wrong with it?
input{ stdin{ } }
output {
azure {
storage_account_name => "some_storage"
container_name => "some_containter"
storage_access_key => "some_secret_key"
}
}
This is the gemspec, is there something wrong?
Gem::Specification.new do |s|
s.name = 'logstash-output-azure'
s.version = '0.1.2'
s.licenses = ['Apache-2.0']
s.summary = 'Plugin for logstash to send output to Microsoft Azure Blob'
#s.description = 'TODO: Write a longer description or delete this line.'
#s.homepage = 'TODO: Put your plugin''s website or public repo URL here.'
s.authors = ['Tuffk']
s.email = '[email protected]'
s.require_paths = ['lib']
# Files
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
# Tests
s.test_files = s.files.grep(%r{^(test|spec|features)/})
# Special flag to let us know this is actually a logstash plugin
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
# Gem dependencies
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
s.add_runtime_dependency "logstash-codec-plain"
s.add_runtime_dependency "azure", "~> 0.7"
s.add_development_dependency "logstash-devutils"
end
And this is a piece of the output.rb file, just to see if the config_name is ok
class LogStash::Outputs::LogstashAzureBlobOutput < LogStash::Outputs::Base
# name for the namespace under output for logstash configuration
config_name "azure"
require 'logstash/outputs/blob/writable_directory_validator'
require 'logstash/outputs/blob/path_validator'
require 'logstash/outputs/blob/size_rotation_policy'
require 'logstash/outputs/blob/time_rotation_policy'
require 'logstash/outputs/blob/size_and_time_rotation_policy'
require 'logstash/outputs/blob/temporary_file'
require 'logstash/outputs/blob/temporary_file_factory'
require 'logstash/outputs/blob/uploader'
require 'logstash/outputs/blob/file_repository'
If you want more information, here is the link to the github repo: https://github.com/tuffk/Logstash-output-to-Azure-Blob
Ive found out what was wrong. The filename of the ruby file under logstash/outputs should be the same as the config_name
Hey @BrunoLerner , I am stuck on a very similar issue, will mention it below.
Can you tell me the filename and path of the file you renamed.
ISSUE - Trying to make changes to https://www.elastic.co/guide/en/logstash/current/plugins-inputs-http.html , but the issue I am facing is I am able to install this plugin using github clone(after removing the same using "bin/logstash-plugin remove logstash-input-http"), but when starting logstash, it fails to recognize "http" as a valid input plugin, pasting a part of stack trace below.
| [2020-02-17T10:32:40,389][ERROR][logstash.plugins.registry] Tried to load a plugin's code, but failed. {:exception=>#
@ashishk1996 I had the same issue and the point is (as mentioned by @BrunoLerner ) the following must be true:
1) file name:
2) inside the previous file:
class LogStash::Inputs::http < LogStash::Inputs::Base
config_name "http"
i.e. the file name must match config_name value. In my case config_name was empty. After fixing this the error is gone (you need to rebuild, uninstall from logstash and install the new build into logstash)
Most helpful comment
Ive found out what was wrong. The filename of the ruby file under logstash/outputs should be the same as the config_name