logstash-plugins / logstash-input-http_poller

Create Logstash events by polling HTTP endpoints!
https://www.elastic.co/guide/en/logstash/current/plugins-inputs-http_poller.html
Apache License 2.0
43 stars 65 forks source link

undefined method `get' for #<Hash:0x46a23c28>\nDid you mean? gem #90

Closed S1rH1ll closed 6 years ago

S1rH1ll commented 6 years ago

Hi,

I am unable to start logstash once I configured the http_poller, I tested the plugin on Windows and Debian Jessie.

logs :

[2017-11-30T10:22:56,915][ERROR][logstash.agent ] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"NoMethodError", :message=>"undefined method get' for #<Hash:0x46a23c28>\nDid you mean? gem", :backtrace=>["/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:210:inexpr'", "org/jruby/RubyArray.java:2486:in map'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:202:inexpr'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:133:in expr'", "org/jruby/RubyArray.java:2486:inmap'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:98:in expr_attributes'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:76:inexpr'", "org/jruby/RubyArray.java:2486:in map'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:69:inexpr'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:48:in block in compile'", "org/jruby/RubyArray.java:1734:ineach'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:46:in compile'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:46:incompile_ast'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:50:in compile_imperative'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:54:incompile_graph'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:12:in block in compile_sources'", "org/jruby/RubyArray.java:2486:inmap'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:11:in compile_sources'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:107:incompile_lir'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:49:in initialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:215:ininitialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:35:in execute'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:335:inblock in converge_state'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:141:in with_pipelines'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:332:inblock in converge_state'", "org/jruby/RubyArray.java:1734:in each'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:319:inconverge_state'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:166:in block in converge_state_and_update'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:141:inwith_pipelines'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:164:in converge_state_and_update'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:90:inexecute'", "/usr/share/logstash/logstash-core/lib/logstash/runner.rb:362:in block in execute'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/stud-0.0.23/lib/stud/task.rb:24:inblock in initialize'"]}

config file :


input {
        http_poller {
                urls => {
                        test1 => "http://ip_adress_removed:9200"
                        test2 => {
        # Supports all options supported by ruby's Manticore HTTP client
                        method => "GET"
                        url => "http://ip_adress_removed:9200/_cluster/health"
                }
    }
    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
  }
}
alext234 commented 6 years ago

Having the same error.

robbavey commented 6 years ago

@S1rH1ll @alext234 Thank you for reporting the issue - this is a known issue in Logstash 6.0.0. The fix will be in the next 6.0.1 and 6.1.0 releases of Logstash, which will be released shortly.

ankitdevnalkar commented 3 years ago

I am still facing this issue in logstash 7.9.2. plugin version : logstash-input-http_poller (5.0.2)

error message : [FATAL] 2020-11-10 07:40:09.980 [LogStash::Runner] runner - The given configuration is invalid. Reason: undefined method get for #<Java::OrgLogstashConfigIrImperative::PluginStatement:0x593fcbe7>

conf file :

# The # character at the beginning of a line indicates a comment. Use
# comments to describe your configuration.
input {
#beats {
#port => "5044"
        http_poller
        {
                urls => {   
            cloudflare => " https://api.cloudflare.com/client/v4/user/audit_logs"
                {
            method => get
                headers => {
                        "X-Auth-Email" => "email@redacted.com"
                        "X-Auth-Key" => "api_key"
                        "Content-Type" => "application/json"
                    }
                }
        }
        }
#}
}
# The filter part of this file is commented out to indicate that it is
# optional.
filter {
        json 
        {
            source => "message"
        }
}
output {
        stdout { codec => rubydebug }
}