# Converting old Ruby code to work with new ruby format of Logstash

**URL:** <https://discuss.elastic.co/t/converting-old-ruby-code-to-work-with-new-ruby-format-of-logstash/119869>\
**Category:** Logstash\
**Created:** [February 14, 2018, 7:24pm UTC](https://discuss.elastic.co/t/converting-old-ruby-code-to-work-with-new-ruby-format-of-logstash/119869 "2018-02-14T19:24:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![magdieldominguez](https://avatars.discourse-cdn.com/v4/letter/m/0ea827/32.png) [@magdieldominguez](https://discuss.elastic.co/u/magdieldominguez)\
**Post date:** [February 14, 2018, 7:24pm UTC](https://discuss.elastic.co/t/converting-old-ruby-code-to-work-with-new-ruby-format-of-logstash/119869/1 "2018-02-14T19:24:43Z")

</div>

Hi I am trying to convert a date field that I have into milliseconds. I found this old post  
[https://discuss.elastic.co/t/logstash-convert-date-string-to-timestamp-in-millisecond/52845](https://discuss.elastic.co/t/logstash-convert-date-string-to-timestamp-in-millisecond/52845)

I am facing the same issue I have a date field exactly as his and I need to convert it to milli seconds his solution to do this was using the Ruby filter and doing this:

ruby {  
code =\> "event['milli'] = 1000\*Time.parse(event['[myDate]']).to\_f"  
}

however when I try to do it on my logstash 6.0.1 i get a Ruby error saying:  
`Direct event field references (i.e. event['field']) have been disabled in favor of using event get and set methods (e.g. event.get('field'))`. But im not sure how to change that Ruby code to work with the new logstash now. Any help would be greatly appreciated thank you!

---

<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:** [February 14, 2018, 8:44pm UTC](https://discuss.elastic.co/t/converting-old-ruby-code-to-work-with-new-ruby-format-of-logstash/119869/2 "2018-02-14T20:44:22Z")

</div>

[https://www.elastic.co/guide/en/logstash/current/event-api.html](https://www.elastic.co/guide/en/logstash/current/event-api.html)

---

<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:** [March 14, 2018, 8:44pm UTC](https://discuss.elastic.co/t/converting-old-ruby-code-to-work-with-new-ruby-format-of-logstash/119869/3 "2018-03-14T20:44:35Z")

</div>

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