# How to use Ruby specific modules in Logstash conf file

**URL:** <https://discuss.elastic.co/t/how-to-use-ruby-specific-modules-in-logstash-conf-file/130819>\
**Category:** Logstash\
**Created:** [May 7, 2018, 11:10am UTC](https://discuss.elastic.co/t/how-to-use-ruby-specific-modules-in-logstash-conf-file/130819 "2018-05-07T11:10:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![santublr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/santublr/32/30862_2.png) [@santublr](https://discuss.elastic.co/u/santublr)\
**Post date:** [May 7, 2018, 11:10am UTC](https://discuss.elastic.co/t/how-to-use-ruby-specific-modules-in-logstash-conf-file/130819/1 "2018-05-07T11:10:02Z")

</div>

Here is the sample conf file. I need to capture each event and do pre-process for that I need to use date and digest/md5 module of ruby.

filter  
{  
ruby {  
init =\> "  
require 'digest/md5'  
require 'date'  
"  
code =\> "

```
 numbers=Digest::MD5.hexdigest('Peter Completed')

 print (numbers + "\n")
 k=DateTime.now.strftime('%Q')
 print (k)
```

---

<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:** [May 7, 2018, 1:13pm UTC](https://discuss.elastic.co/t/how-to-use-ruby-specific-modules-in-logstash-conf-file/130819/2 "2018-05-07T13:13:25Z")

</div>

Aaaand this isn't working? What's the error message?

You can't use double quotes in the code block is you're using double quotes to delimit the code block itself.

---

<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:** [June 4, 2018, 1:13pm UTC](https://discuss.elastic.co/t/how-to-use-ruby-specific-modules-in-logstash-conf-file/130819/3 "2018-06-04T13:13:29Z")

</div>

Closed on June 4, 2018, 1:13pm UTC

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