# Greater than not working in logstash filter and crashing

**URL:** https://discuss.elastic.co/t/greater-than-not-working-in-logstash-filter-and-crashing/109249
**Category:** Logstash
**Created:** [November 27, 2017, 4:23pm UTC](https://discuss.elastic.co/t/greater-than-not-working-in-logstash-filter-and-crashing/109249 "2017-11-27T16:23:53Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![zzurashvili](https://avatars.discourse-cdn.com/v4/letter/z/5fc32e/32.png) [@zzurashvili](https://discuss.elastic.co/u/zzurashvili)
#### Post date: [November 27, 2017, 4:23pm UTC](https://discuss.elastic.co/t/greater-than-not-working-in-logstash-filter-and-crashing/109249/1 "2017-11-27T16:23:53Z")

</div>

I'm getting IPFIX flow data and in filter I need to add fields and tags based on source or destination port. Everything is working perfectly when I compare port using "==". if I use "\>" I get:

[2017-11-27T11:18:45,502][ERROR][logstash.pipeline] Exception in pipelineworker, the pipeline stopped processing new events, please check your filter configuration and restart Logstash. {"exception"=\>"undefined method `>' for nil:NilClass", "backtrace"=>["(eval):881:in`initialize'", "org/jruby/RubyArray.java:1613:in `each'", "(eval):801:in`initialize'", "org/jruby/RubyProc.java:281:in `call'", "(eval):689:in`filter\_func'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:398:in `filter_batch'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:379:in`worker\_loop'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:342:in `start_workers'"]} [2017-11-27T11:18:45,557][FATAL][logstash.runner] An unexpected error occurred! {:error=>#<NoMethodError: undefined method`\>' for nil:NilClass\>, :backtrace=\>["(eval):881:in `initialize'", "org/jruby/RubyArray.java:1613:in`each'", "(eval):801:in `initialize'", "org/jruby/RubyProc.java:281:in`call'", "(eval):689:in `filter_func'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:398:in`filter\_batch'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:379:in `worker_loop'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:342:in`start\_workers'"]}  
""  
so If I just use these  
if [ipfix][destinationTransportPort] == 22 or [ipfix][sourceTransportPort] == 22 {  
mutate { add\_field =\> { "app" =\> "scp" } }  
else if [ipfix][destinationTransportPort] == 53 or [ipfix][sourceTransportPort] == 53 {  
mutate { add\_field =\> { "app" =\> "dns" } }  
else if [ipfix][destinationTransportPort] == 80 or [ipfix][sourceTransportPort] == 80 {  
mutate { add\_field =\> { "app" =\> "web" } }  
it's working without any problem.

but if I use "\>" instead of == then ny logstash daemon is crashing and getting Exception in pipelineworker.

snippet which is causing crash:  
if [ipfix][destinationTransportPort] == 22 or [ipfix][sourceTransportPort] == 22 {  
mutate { add\_field =\> { "app" =\> "scp" } }  
else if [ipfix][destinationTransportPort] == 53 or [ipfix][sourceTransportPort] == 53 {  
mutate { add\_field =\> { "app" =\> "dns" } }  
else if [ipfix][destinationTransportPort] \> 80 {  
mutate { add\_field =\> { "app" =\> "web" } }

thanks in advance for any comment/help

---

<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: [November 27, 2017, 9:00pm UTC](https://discuss.elastic.co/t/greater-than-not-working-in-logstash-filter-and-crashing/109249/2 "2017-11-27T21:00:34Z")

</div>

The event doesn't have a `[ipfix][destinationTransportPort]` field. You can modify your conditional to

```
else if [ipfix][destinationTransportPort] and [ipfix][destinationTransportPort] > 80 {

```

to make sure you don't attempt to evaluate the `>` operator unless the field exists.

---

<div class="post-metadata">

### Author: ![zzurashvili](https://avatars.discourse-cdn.com/v4/letter/z/5fc32e/32.png) [@zzurashvili](https://discuss.elastic.co/u/zzurashvili)
#### Post date: [November 27, 2017, 9:55pm UTC](https://discuss.elastic.co/t/greater-than-not-working-in-logstash-filter-and-crashing/109249/3 "2017-11-27T21:55:24Z")

</div>

it worked!  
thanks a lot!

---

<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 25, 2017, 9:55pm UTC](https://discuss.elastic.co/t/greater-than-not-working-in-logstash-filter-and-crashing/109249/4 "2017-12-25T21:55:32Z")

</div>

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