# After upgrading to logstash6 ruby code stop working

**URL:** <https://discuss.elastic.co/t/after-upgrading-to-logstash6-ruby-code-stop-working/127811>\
**Category:** Logstash\
**Created:** [April 12, 2018, 12:12pm UTC](https://discuss.elastic.co/t/after-upgrading-to-logstash6-ruby-code-stop-working/127811 "2018-04-12T12:12:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yossiv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yossiv/32/10662_2.png) [@yossiv](https://discuss.elastic.co/u/yossiv)\
**Post date:** [April 12, 2018, 12:12pm UTC](https://discuss.elastic.co/t/after-upgrading-to-logstash6-ruby-code-stop-working/127811/1 "2018-04-12T12:12:53Z")

</div>

Hi all.  
i would like to get your help converting my below code to the new ruby code.  
after i upgraded to logstash6 ( from logstash2) this math function stop working  
i need to calculate the profit .  
i know it has changed to event.set and event.get , but its not working for me.  
thanks .

# ruby {

# code =\> "event['Profit'] = (event['K2\_TotalBetPlaced'].to\_f - event['K2\_WinAmount'].to\_f).round(2)"

# }

---

<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:** [April 12, 2018, 12:26pm UTC](https://discuss.elastic.co/t/after-upgrading-to-logstash6-ruby-code-stop-working/127811/2 "2018-04-12T12:26:31Z")

</div>

```
event.set('Profit', (event.get('K2_TotalBetPlaced').to_f - event.get('K2_WinAmount').to_f).round(2))
```

---

<div class="post-metadata">

**Author:** ![yossiv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yossiv/32/10662_2.png) [@yossiv](https://discuss.elastic.co/u/yossiv)\
**Post date:** [April 12, 2018, 12:52pm UTC](https://discuss.elastic.co/t/after-upgrading-to-logstash6-ruby-code-stop-working/127811/3 "2018-04-12T12:52:57Z")

</div>

many thanks!  
works

---

<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:** [May 10, 2018, 12:53pm UTC](https://discuss.elastic.co/t/after-upgrading-to-logstash6-ruby-code-stop-working/127811/4 "2018-05-10T12:53:09Z")

</div>

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