# Undefined method \`get' for

**URL:** <https://discuss.elastic.co/t/undefined-method-get-for/255214>\
**Category:** Logstash\
**Created:** [November 12, 2020, 1:13pm UTC](https://discuss.elastic.co/t/undefined-method-get-for/255214 "2020-11-12T13:13:59Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankitdevnalkar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ankitdevnalkar/32/46158_2.png) [@ankitdevnalkar](https://discuss.elastic.co/u/ankitdevnalkar)\
**Post date:** [November 12, 2020, 1:13pm UTC](https://discuss.elastic.co/t/undefined-method-get-for/255214/1 "2020-11-12T13:13:59Z")

</div>

I am facing bellow error while using **http\_poller**. I am trying to pull cloudflare API logs in json format. Here is my `.conf` file. I am using `logstash 7.9.2` and `logstash-input-http_poller (5.0.2)`  
Can anyone please help ?

**configuration 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" => "me@company.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 }
}

```

**Error message :**

```
/usr/share/logstash/bin/logstash -f cloudflare.conf --config.reload.automatic
    WARNING: Could not find logstash.yml which is typically located in $LS_HOME/config or /etc/logstash. You can specify the path using --path.settings. Continuing using the defaults
    Could not find log4j2 configuration at path /usr/share/logstash/config/log4j2.properties. Using default config which logs errors to the console
    [INFO] 2020-11-12 12:38:38.566 [main] runner - Starting Logstash {"logstash.version"=>"7.9.2", "jruby.version"=>"jruby 9.2.13.0 (2.5.7) 2020-08-03 9a89c94bcc OpenJDK 64-Bit Server VM 25.272-b10 on 1.8.0_272-8u272-b10-0ubuntu1~16.04-b10 +indy +jit [linux-x86_64]"}
    [WARN] 2020-11-12 12:38:39.160 [LogStash::Runner] multilocal - Ignoring the 'pipelines.yml' file because modules or command line options are specified
    [ERROR] 2020-11-12 12:38:40.581 [Converge PipelineAction::Create<main>] agent - Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"NoMethodError", :message=>"undefined method `get' for #<Java::OrgLogstashConfigIrImperative::PluginStatement:0x48942d22>", :backtrace=>["/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:227:in `expr'", "org/jruby/RubyArray.java:2577:in `map'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:219:in `expr'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:150:in `expr'", "org/jruby/RubyArray.java:2577:in `map'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:114:in `expr_attributes'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:92:in `expr'", "org/jruby/RubyArray.java:2577:in `map'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:85:in `expr'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:64:in `block in compile'", "org/jruby/RubyArray.java:1809:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:62:in `compile'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:36:in `compile_imperative'", "org/logstash/execution/AbstractPipelineExt.java:183:in `initialize'", "org/logstash/execution/JavaBasePipelineExt.java:69:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:44:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:52:in `execute'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:357:in `block in converge_state'"]}
    [INFO] 2020-11-12 12:38:40.839 [Api Webserver] agent - Successfully started Logstash API endpoint {:port=>9600}
    [ERROR] 2020-11-12 12:38:43.917 [Converge PipelineAction::Create<main>] agent - Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"NoMethodError", :message=>"undefined method `get' for #<Java::OrgLogstashConfigIrImperative::PluginStatement:0x3edffe50>", :backtrace=>["/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:227:in `expr'", "org/jruby/RubyArray.java:2577:in `map'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:219:in `expr'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:150:in `expr'", "org/jruby/RubyArray.java:2577:in `map'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:114:in `expr_attributes'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:92:in `expr'", "org/jruby/RubyArray.java:2577:in `map'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:85:in `expr'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:64:in `block in compile'", "org/jruby/RubyArray.java:1809:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/compiler/lscl.rb:62:in `compile'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:36:in `compile_imperative'", "org/logstash/execution/AbstractPipelineExt.java:183:in `initialize'", "org/logstash/execution/JavaBasePipelineExt.java:69:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:44:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:52:in `execute'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:357:in `block in converge_state'"]}
```

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [November 12, 2020, 1:50pm UTC](https://discuss.elastic.co/t/undefined-method-get-for/255214/2 "2020-11-12T13:50:02Z")

</div>

Where is your `logstash.yml` located? You probably need to add `--path.settings SETTINGS_DIR` to your command to give it the path of it.

`/usr/share/logstash/bin/logstash -f cloudflare.conf --config.reload.automatic --path.settings /etc/elasticsearch`

---

<div class="post-metadata">

**Author:** ![ankitdevnalkar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ankitdevnalkar/32/46158_2.png) [@ankitdevnalkar](https://discuss.elastic.co/u/ankitdevnalkar)\
**Post date:** [November 12, 2020, 2:15pm UTC](https://discuss.elastic.co/t/undefined-method-get-for/255214/3 "2020-11-12T14:15:52Z")

</div>

I ran command `/usr/share/logstash/bin/logstash -f cloudflare.conf --config.reload.automatic --path.settings /etc/logstash/`. getting following error. I am running logstash from command line only for now until I get the API data in my terminal. Also, `logstash.yml` is located at `/etc/logstash`

Also, just for information, Elasticsearch,Logstash and Kibana all are running individually on separate instances.

```
Sending Logstash logs to /var/log/logstash which is now configured via log4j2.properties
[2020-11-12T14:06:03,302][INFO][logstash.runner] Starting Logstash {"logstash.version"=>"7.9.2", "jruby.version"=>"jruby 9.2.13.0 (2.5.7) 2020-08-03 9a89c94bcc OpenJDK 64-Bit Server VM 25.272-b10 on 1.8.0_272-8u272-b10-0ubuntu1~16.04-b10 +indy +jit [linux-x86_64]"}
[2020-11-12T14:06:03,502][ERROR][logstash.configmanagement.bootstrapcheck] There are config files (1) in the 'cloudflare.conf' folder. Elasticsearch is configured as the config store so configs cannot be sourced via the command line with -f or via logstash.yml with path.config
ERROR: There are config files (1) in the 'cloudflare.conf' folder. Elasticsearch is configured as the config store so configs cannot be sourced via the command line with -f or via logstash.yml with path.config`

```

I was wondering in your command if you wrote following by typo or intentionally.

> [@aaron-nimocks](#):
>
> /etc/elasticsearch

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [November 12, 2020, 2:22pm UTC](https://discuss.elastic.co/t/undefined-method-get-for/255214/4 "2020-11-12T14:22:06Z")

</div>

I said `/etc/elasticsearch` because that was the most likely location. So now your pipeline is actually running.

Do you have [centralized pipeline enabled](https://www.elastic.co/guide/en/logstash/6.6/configuring-centralized-pipelines.html#configuring-centralized-pipelines)? If so I don't think you can run this via command line according to [this](https://discuss.elastic.co/t/logstash-problem-with-elasticsearch/111795/7).

---

<div class="post-metadata">

**Author:** ![ankitdevnalkar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ankitdevnalkar/32/46158_2.png) [@ankitdevnalkar](https://discuss.elastic.co/u/ankitdevnalkar)\
**Post date:** [November 12, 2020, 2:32pm UTC](https://discuss.elastic.co/t/undefined-method-get-for/255214/5 "2020-11-12T14:32:05Z")

</div>

No,`centralized pipeline` is not enabled.

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [November 12, 2020, 3:02pm UTC](https://discuss.elastic.co/t/undefined-method-get-for/255214/6 "2020-11-12T15:02:21Z")

</div>

Not sure what directory you are running this from so try adding the full path to your `-f cloudflare.conf`

---

<div class="post-metadata">

**Author:** ![ankitdevnalkar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ankitdevnalkar/32/46158_2.png) [@ankitdevnalkar](https://discuss.elastic.co/u/ankitdevnalkar)\
**Post date:** [November 12, 2020, 3:10pm UTC](https://discuss.elastic.co/t/undefined-method-get-for/255214/7 "2020-11-12T15:10:28Z")

</div>

I am running it from correct directory. In fact, I tried ingesting log file with following configuration and it is working ok and showing me json data on screen. I am facing problem with http\_poller only.

```
# The # character at the beginning of a line indicates a comment. Use
# comments to describe your configuration.
input {
	file 
	{
		path => "/home/ubuntu/cloudflare/cloudflare.log"
		start_position => beginning
		codec => json{ charset => "UTF-8" }
	}
}
# The filter part of this file is commented out to indicate that it is
# optional.
filter {
        json 
        {
            source => "result"
        }
}
output {
        stdout { codec => rubydebug }
}
```

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [November 12, 2020, 3:17pm UTC](https://discuss.elastic.co/t/undefined-method-get-for/255214/8 "2020-11-12T15:17:21Z")

</div>

Got it. Does the below work for you?

```auto
input {
   http_poller {
      urls => {
         urlname => "http://www.google.com"
      }
      request_timeout => 20
      schedule => { every =>"5s"}  
      codec => "line"
   }
}

```

---

<div class="post-metadata">

**Author:** ![ankitdevnalkar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ankitdevnalkar/32/46158_2.png) [@ankitdevnalkar](https://discuss.elastic.co/u/ankitdevnalkar)\
**Post date:** [November 12, 2020, 3:25pm UTC](https://discuss.elastic.co/t/undefined-method-get-for/255214/9 "2020-11-12T15:25:09Z")

</div>

yes it is working fine.

> [@aaron-nimocks](#):
>
> ```auto
> input {
> http_poller {
> urls => {
> urlname => "http://www.google.com"
> }
> request_timeout => 20
> schedule => { every =>"5s"}  
> codec => "line"
> }
> }
> 
> ```

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [November 12, 2020, 3:28pm UTC](https://discuss.elastic.co/t/undefined-method-get-for/255214/10 "2020-11-12T15:28:16Z")

</div>

> [@ankitdevnalkar](#):
>
> `cloudflare => " https://api.cloudflare.com/client/v4/user/audit_logs"`

Try removing the space between `" https`

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [November 12, 2020, 3:38pm UTC](https://discuss.elastic.co/t/undefined-method-get-for/255214/11 "2020-11-12T15:38:04Z")

</div>

@ankitdevnalkar this works for me. But of course it returns an authentication error.

```auto
input {
  http_poller {
    urls => {
      test2 => {
        method => get
        url => "https://api.cloudflare.com/client/v4/user/audit_logs"
        headers => {
            "X-Auth-Email" => "me@company.com"
            "X-Auth-Key" => "api_key"
            "Content-Type" => "application/json"
        }
     }
    }
    schedule => { cron => "* * * * * UTC"}
    codec => "json"
  }
}
output {
        stdout { codec => rubydebug }
}

```

---

<div class="post-metadata">

**Author:** ![ankitdevnalkar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ankitdevnalkar/32/46158_2.png) [@ankitdevnalkar](https://discuss.elastic.co/u/ankitdevnalkar)\
**Post date:** [November 12, 2020, 4:25pm UTC](https://discuss.elastic.co/t/undefined-method-get-for/255214/12 "2020-11-12T16:25:25Z")

</div>

hey @aaron-nimocks it worked 🚀 !! I was missing `test2` part in my code.  
Thanks buddy ! made my day 😁

> [@aaron-nimocks](#):
>
> ```auto
> urls => {
> test2 => {
> method => get
> url => "https://api.cloudflare.com/client/v4/user/audit_logs"
> 
> ```

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [November 12, 2020, 4:32pm UTC](https://discuss.elastic.co/t/undefined-method-get-for/255214/13 "2020-11-12T16:32:47Z")

</div>

No problem. You can rename that to whatever you want. Glad it's working! 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 10, 2020, 4:32pm UTC](https://discuss.elastic.co/t/undefined-method-get-for/255214/14 "2020-12-10T16:32:49Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
