Search code examples
elasticsearchlogstash

Logstash: TypeError: no implicit conversion of nil into string


I'm new to ELK and trying to input 3rd party REST API to Logstash to feed data into it. I'm getting TypeError: no implicit conversion of nil into string.

I'm using http_input_poller plugin to feed data. Here is configuration for it.

input {
  http_poller {
    urls => {
      test1 => "https://example.com/api/now/table/sys_user?sysparm_limit=1"
    }
    request_timeout => 60
    # Supports "cron", "every", "at" and "in" schedules by rufus scheduler
    schedule => { cron => "* * * * * UTC"}
    codec => "json"
    # A hash of request metadata info (timing, response headers, etc.) will be sent here
    metadata_target => "http_poller_metadata"
  }
}

output {
  stdout {
    codec => rubydebug
  }
}

I'm using this command to run

sudo ./logstash -f logstash_http_poller.conf --path.settings /etc/logstash/ --path.data

I'm getting this error message

masteradmin@usr:/usr/share/logstash/bin$ sudo ./logstash -f logstash_http_poller.conf --path.settings /etc/logstash/ --path.data
[FATAL] 2020-03-18 07:07:07.377 [main] runner - An unexpected error occurred! {:error=>#<TypeError: no implicit conversion of nil into String>, :backtrace=>["org/jruby/RubyFileTest.java:96:in `directory?'", "org/jruby/RubyFileTest.java:88:in `directory?'", "/usr/share/logstash/logstash-core/lib/logstash/settings.rb:510:in `block in value'", "org/jruby/RubyKernel.java:1906:in `tap'", "/usr/share/logstash/logstash-core/lib/logstash/settings.rb:509:in `value'", "/usr/share/logstash/logstash-core/lib/logstash/settings.rb:97:in `get_value'", "/usr/share/logstash/logstash-core/lib/logstash/environment.rb:94:in `block in LogStash'", "/usr/share/logstash/logstash-core/lib/logstash/settings.rb:167:in `block in post_process'", "org/jruby/RubyArray.java:1814:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/settings.rb:166:in `post_process'", "/usr/share/logstash/logstash-core/lib/logstash/util/settings_helper.rb:26:in `post_process'", "/usr/share/logstash/logstash-core/lib/logstash/runner.rb:246:in `execute'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb:67:in `run'", "/usr/share/logstash/logstash-core/lib/logstash/runner.rb:242:in `run'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/lib/clamp/command.rb:132:in `run'", "/usr/share/logstash/lib/bootstrap/environment.rb:73:in `<main>'"]}
[ERROR] 2020-03-18 07:07:07.386 [main] Logstash - java.lang.IllegalStateException: Logstash stopped processing because of an error: (SystemExit) exit

Need help. Thanks


Solution

  • After some analysis of the error message I strongly believe that this error occurres due to the fact that no value for the --path.data argument was specified.

    • TypeError: no implicit conversion of nil into String> could indicate that nil (the non-existent path) can not be converted to a string (what the path/argument value has to be)

    • RubyFileTest.java:96:in ``directory?'" indicates that the ruby class expected a valid directory

    So please specify a value for the argument in your run command and let me know if that solved the issue.

    EDIT:

    The path.data argument is not mandatory, so you can remove it. The default location would then be the data-folder inside the directory you extracted the binaries. (See https://www.elastic.co/guide/en/logstash/current/dir-layout.html for reference)