# Ruby Scripts in Logstash CONF file

**URL:** <https://discuss.elastic.co/t/ruby-scripts-in-logstash-conf-file/135322>\
**Category:** Logstash\
**Created:** [June 11, 2018, 9:32am UTC](https://discuss.elastic.co/t/ruby-scripts-in-logstash-conf-file/135322 "2018-06-11T09:32:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul1243](https://avatars.discourse-cdn.com/v4/letter/p/e99b99/32.png) [@paul1243](https://discuss.elastic.co/u/paul1243)\
**Post date:** [June 11, 2018, 9:32am UTC](https://discuss.elastic.co/t/ruby-scripts-in-logstash-conf-file/135322/1 "2018-06-11T09:32:37Z")

</div>

Hi-  
I have did the logs transformation using the Ruby code on Logstash pipelines and running the CONF file from a Virtual machine. The ruby code is getting bigger, and found its risky to have the code on a Virtual machine.

I was just thinking if I can commit the logstash CONF file on the GIT, Is there a way that I can get the CONF script from Git and trigger it (like what Jenkins does)?

The second option I have is, to write as a the methods and create a Ruby GEM and call it in the .CONF File ?

Please advise.

---

<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:** [June 12, 2018, 6:46am UTC](https://discuss.elastic.co/t/ruby-scripts-in-logstash-conf-file/135322/2 "2018-06-12T06:46:46Z")

</div>

You can store the Ruby code in a file of its own and that file can be stored in a Git repository, but Logstash has no built-in support for cloning gits.

---

<div class="post-metadata">

**Author:** ![paul1243](https://avatars.discourse-cdn.com/v4/letter/p/e99b99/32.png) [@paul1243](https://discuss.elastic.co/u/paul1243)\
**Post date:** [June 13, 2018, 5:54am UTC](https://discuss.elastic.co/t/ruby-scripts-in-logstash-conf-file/135322/3 "2018-06-13T05:54:25Z")

</div>

Thanks for your response @magnusbaeck  
I was just thinking, to put all the ruby methods and create a GEM and install it on logstash, and just call that methods in the CONF file ? Is that feasible ? Please let me know. Thanks !

---

<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:** [June 13, 2018, 6:10am UTC](https://discuss.elastic.co/t/ruby-scripts-in-logstash-conf-file/135322/4 "2018-06-13T06:10:16Z")

</div>

That might work, but I'd probably write a proper filter plugin instead.

---

<div class="post-metadata">

**Author:** ![paul1243](https://avatars.discourse-cdn.com/v4/letter/p/e99b99/32.png) [@paul1243](https://discuss.elastic.co/u/paul1243)\
**Post date:** [June 15, 2018, 7:30am UTC](https://discuss.elastic.co/t/ruby-scripts-in-logstash-conf-file/135322/5 "2018-06-15T07:30:19Z")

</div>

Sure, Thanks for the inputs @magnusbaeck  
I have cloned a existing repository and tried doing the bundle install to get the dependencies, but I get the below error message:

```auto
Could not find gem 'logstash-devutils (~> 0.0.18) x86-mingw32' in any of the gem

```

I've the ruby version as 2.3 and working on the Windows 64 bit machine. Could you please let me know how do I resolve this issue ? Thanks !

---

<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:** [June 15, 2018, 7:32am UTC](https://discuss.elastic.co/t/ruby-scripts-in-logstash-conf-file/135322/6 "2018-06-15T07:32:01Z")

</div>

My only suggestion is that you should make sure you've chosen JRuby as your current Ruby.

---

<div class="post-metadata">

**Author:** ![paul1243](https://avatars.discourse-cdn.com/v4/letter/p/e99b99/32.png) [@paul1243](https://discuss.elastic.co/u/paul1243)\
**Post date:** [June 16, 2018, 11:35am UTC](https://discuss.elastic.co/t/ruby-scripts-in-logstash-conf-file/135322/7 "2018-06-16T11:35:43Z")

</div>

Thanks @magnusbaeck.  
I cloned a logstash filter repository from GIThub and did the bundle install with Jruby and it was all fine.  
When I tried to run any spec file I get some error message for the dependencies:

```auto
RuntimeError:

  	you might need to reinstall the gem which depends on the missing jar or in case there is Jars.lock then resolve the jars with `lock_jars` command

  no such file to load -- org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21 (LoadError)

```

Could you please let me know do I resolve this sort of dependencies issues.

Jruby Version - jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 Java HotSpot(TM) 64-Bit Server VM 25.11  
1-b14 on 1.8.0\_111-b14 +jit [mswin32-x86\_64]

Ruby Version - ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]

Thanks !

---

<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 14, 2018, 11:36am UTC](https://discuss.elastic.co/t/ruby-scripts-in-logstash-conf-file/135322/8 "2018-07-14T11:36:00Z")

</div>

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