# Logstash: NoMethodError: method \`\>=' for nil:NilClass

**URL:** https://discuss.elastic.co/t/logstash-nomethoderror-method-for-nil-nilclass/52622
**Category:** Logstash
**Created:** [June 13, 2016, 2:21pm UTC](https://discuss.elastic.co/t/logstash-nomethoderror-method-for-nil-nilclass/52622 "2016-06-13T14:21:18Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![sen](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@sen](https://discuss.elastic.co/u/sen)
#### Post date: [June 13, 2016, 2:21pm UTC](https://discuss.elastic.co/t/logstash-nomethoderror-method-for-nil-nilclass/52622/1 "2016-06-13T14:21:18Z")

</div>

Hello everyone,

Here is my configuration file:  
input {  
stdin { }  
file {  
path =\> ["myfile.json"]  
type =\> "bytel"  
codec =\> "json"  
}  
}

filter {

```
if [log][Frequency] != [] {
    if [log][Frequency] >= 866.0 {
        mutate {
            add_field => ["[log][subband]", "7"] 
        }
   }
}

```

}

output {  
elasticsearch {  
hosts =\> ["localhost:9200"]  
index =\> "test"  
}  
stdout { codec =\> rubydebug }  
}

I got the folloing error :  
Exception in pipelineworker, the pipeline stopped processing new events, please check your filter configuration and restart Logstash. {"exception"=\>#\<NoMethodError: undefined method `>=' for nil:NilClass>, "backtrace"=>["(eval):177:in`cond\_func\_4'", "org/jruby/RubyArray.java:1613:in `each'", "(eval):175:in`cond\_func\_4'", "(eval):192:in `cond_func_3'", "org/jruby/RubyArray.java:1613:in`each'", "(eval):189:in `cond_func_3'", "(eval):131:in`filter\_func'", "/home/sagemcom/ELK/logstash-2.2.4/vendor/bundle/jruby/1.9/gems/logstash-core-2.2.4-java/lib/logstash/pipeline.rb:259:in `filter_batch'", "org/jruby/RubyArray.java:1613:in`each'", "org/jruby/RubyEnumerable.java:852:in `inject'", "/home/sagemcom/ELK/logstash-2.2.4/vendor/bundle/jruby/1.9/gems/logstash-core-2.2.4-java/lib/logstash/pipeline.rb:257:in`filter\_batch'", "/home/sagemcom/ELK/logstash-2.2.4/vendor/bundle/jruby/1.9/gems/logstash-core-2.2.4-java/lib/logstash/pipeline.rb:215:in `worker_loop'", "/home/sagemcom/ELK/logstash-2.2.4/vendor/bundle/jruby/1.9/gems/logstash-core-2.2.4-java/lib/logstash/pipeline.rb:193:in`start\_workers'"], :level=\>:error}  
Exception in pipelineworker, the pipeline stopped processing new events, please check your filter configuration and restart Logstash. {"exception"=\>#\<NoMethodError: undefined method `>=' for nil:NilClass>, "backtrace"=>["(eval):177:in`cond\_func\_4'", "org/jruby/RubyArray.java:1613:in `each'", "(eval):175:in`cond\_func\_4'", "(eval):192:in `cond_func_3'", "org/jruby/RubyArray.java:1613:in`each'", "(eval):189:in `cond_func_3'", "(eval):131:in`filter\_func'", "/home/sagemcom/ELK/logstash-2.2.4/vendor/bundle/jruby/1.9/gems/logstash-core-2.2.4-java/lib/logstash/pipeline.rb:259:in `filter_batch'", "org/jruby/RubyArray.java:1613:in`each'", "org/jruby/RubyEnumerable.java:852:in `inject'", "/home/sagemcom/ELK/logstash-2.2.4/vendor/bundle/jruby/1.9/gems/logstash-core-2.2.4-java/lib/logstash/pipeline.rb:257:in`filter\_batch'", "/home/sagemcom/ELK/logstash-2.2.4/vendor/bundle/jruby/1.9/gems/logstash-core-2.2.4-java/lib/logstash/pipeline.rb:215:in `worker_loop'", "/home/sagemcom/ELK/logstash-2.2.4/vendor/bundle/jruby/1.9/gems/logstash-core-2.2.4-java/lib/logstash/pipeline.rb:193:in`start\_workers'"], :level=\>:error}  
NoMethodError: undefined method `\>=' for nil:NilClass  
cond\_func\_4 at (eval):177  
each at org/jruby/RubyArray.java:1613  
cond\_func\_4 at (eval):175  
cond\_func\_3 at (eval):192  
each at org/jruby/RubyArray.java:1613  
cond\_func\_3 at (eval):189  
filter\_func at (eval):131

Do you how to solve this problem please ?!!

Thank you for your attention and your help.

S

---

<div class="post-metadata">

### Author: ![marke72](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marke72/32/10832_2.png) [@marke72](https://discuss.elastic.co/u/marke72)
#### Post date: [June 13, 2016, 4:50pm UTC](https://discuss.elastic.co/t/logstash-nomethoderror-method-for-nil-nilclass/52622/2 "2016-06-13T16:50:02Z")

</div>

So I'm not 100% why this is but it seems that you need to add this before you do the comparison:

mutate {  
convert =\> { "[log][Frequency]" =\> "integer" }  
}

My guess is that Logstash is reading that field as a string and the error is being thrown because it can't compare a String to an Integer. It just needs to be converted from a String to an Integer.

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [June 13, 2016, 8:14pm UTC](https://discuss.elastic.co/t/logstash-nomethoderror-method-for-nil-nilclass/52622/3 "2016-06-13T20:14:50Z")

</div>

The line

```
if [log][Frequency] != [] {

```

probably checks if the field in question is equal to an empty array, which it isn't, so it continues with the next conditional. You probably want to check if the field is defined:

```
if [log][Frequency] {
```

---

<div class="post-metadata">

### Author: ![sen](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@sen](https://discuss.elastic.co/u/sen)
#### Post date: [June 14, 2016, 8:45am UTC](https://discuss.elastic.co/t/logstash-nomethoderror-method-for-nil-nilclass/52622/4 "2016-06-14T08:45:59Z")

</div>

it works. Thank you !

---

<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: [July 6, 2017, 4:53am UTC](https://discuss.elastic.co/t/logstash-nomethoderror-method-for-nil-nilclass/52622/5 "2017-07-06T04:53:07Z")

</div>


