# \[Resolved\] Ruby filter exceptions in 5.0.0

**URL:** <https://discuss.elastic.co/t/resolved-ruby-filter-exceptions-in-5-0-0/56643>\
**Category:** Logstash\
**Created:** [July 28, 2016, 3:06pm UTC](https://discuss.elastic.co/t/resolved-ruby-filter-exceptions-in-5-0-0/56643 "2016-07-28T15:06:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rom1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rom1/32/49699_2.png) [@Rom1](https://discuss.elastic.co/u/Rom1)\
**Post date:** [July 28, 2016, 3:06pm UTC](https://discuss.elastic.co/t/resolved-ruby-filter-exceptions-in-5-0-0/56643/1 "2016-07-28T15:06:22Z")

</div>

Hi,

I want to create a new field by computing hour, minute and second in seconds with logstash 5.0.0-alpha4.  
I'm using :

> ruby {  
> code =\> "event['duration'] = event['dur\_hour'] \* 3600 + event['dur\_min'] \* 60 + event['dur\_sec']"  
> remove\_field =\> ["dur\_hour", "dur\_min", "dur\_sec"]  
> }

The fields `dur_hour`, `dur_min` and `dur_sec` are integers :

- grok pattern = "%{HOUR:dur\_hour:int}:%{MINUTE:dur\_min:int}:%{SECOND:dur\_sec:int}"
- the result is

> "dur\_hour" =\> 0,  
> "dur\_sec" =\> 1,  
> "dur\_min" =\> 1,

I've got a \_rubyexception that I can't explain

If I put an empty code (like `code => ""` or `";"`) there is no exception (I checked it by adding a `remove_filed` command to delete `dur_hour`)  
If I put a simple code (like `event['duration'] = 1000`) there is an exception : \_rubyexception

How can I debug ruby to have more information ?  
Is this problem linked to the version of logstash ?

Thank for your help

**EDIT :**  
Some more information,

- the code above works with Logstash 2.3.4.
- When I start Logstash 5.0.0-alpha4 I've this message :

> ` --- jar coordinate com.fasterxml.jackson.core:jackson-annotations already loaded with version 2.7.1 - omit version 2.7.0 --- jar coordinate com.fasterxml.jackson.core:jackson-databind already loaded with version 2.7.1 - omit version 2.7.1-1`

---

<div class="post-metadata">

**Author:** ![Rom1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rom1/32/49699_2.png) [@Rom1](https://discuss.elastic.co/u/Rom1)\
**Post date:** [August 3, 2016, 3:16pm UTC](https://discuss.elastic.co/t/resolved-ruby-filter-exceptions-in-5-0-0/56643/2 "2016-08-03T15:16:36Z")

</div>

**SOLUTION**  
Ruby getters and setters have been refactored in 5.0.0  
Found there : [https://github.com/elastic/logstash/issues/5141](https://github.com/elastic/logstash/issues/5141)

This works fine :

> code =\> "event.set('duration', event.get('dur\_hour') \* 3600 + event.get('dur\_min') \* 60 + event.get('dur\_sec'))"

---

<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:45am UTC](https://discuss.elastic.co/t/resolved-ruby-filter-exceptions-in-5-0-0/56643/3 "2017-07-06T04:45:05Z")

</div>

Closed on July 6, 2017, 4:45am UTC


