# Installing Gem for Ruby Filter Plugin

**URL:** <https://discuss.elastic.co/t/installing-gem-for-ruby-filter-plugin/79994>\
**Category:** Logstash\
**Created:** [March 25, 2017, 4:25pm UTC](https://discuss.elastic.co/t/installing-gem-for-ruby-filter-plugin/79994 "2017-03-25T16:25:44Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![uschtwill](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/uschtwill/32/14077_2.png) [@uschtwill](https://discuss.elastic.co/u/uschtwill)\
**Post date:** [March 25, 2017, 4:25pm UTC](https://discuss.elastic.co/t/installing-gem-for-ruby-filter-plugin/79994/1 "2017-03-25T16:25:44Z")

</div>

Hello there,

I am trying to install the `jdbc-mysql` gem in a dockerized Logstash (after I miserably failed to set `Xcext.enabled=true` and use the `mysql2` gem).

In the Dockerfile I am first running this

`RUN env GEM_HOME=/opt/logstash/vendor/bundle/jruby/1.9 /usr/share/logstash/vendor/jruby/bin/jruby /usr/share/logstash/vendor/jruby/bin/gem install jdbc-mysql`

to install the gem and then the following to add it to the filter's gemspec:

`RUN head -n -2 ./vendor/bundle/jruby/1.9/gems/logstash-filter-ruby-3.0.2/logstash-filter-ruby.gemspec > ./vendor/bundle/jruby/1.9/gems/logstash-filter-ruby-3.0.2/logstash-filter-ruby.gemspec.temp; mv ./vendor/bundle/jruby/1.9/gems/logstash-filter-ruby-3.0.2/logstash-filter-ruby.gemspec.temp ./vendor/bundle/jruby/1.9/gems/logstash-filter-ruby-3.0.2/logstash-filter-ruby.gemspec`  
`RUN echo "s.add_runtime_dependency 'jdbc-mysql\nend'" >> ./vendor/bundle/jruby/1.9/gems/logstash-filter-ruby-3.0.2/logstash-filter-ruby.gemspec`

But it's still not working, but complainig like so:

`ERROR logstash.filters.ruby - Ruby exception occurred: no such file to load -- jdbc/mysql`

Is this actually the right way to do it? Or is there another, better and easier way to achieve this? All I really want to do is query MySQL from that filter. 😕

[How to add new gem for my plugin usage?](https://discuss.elastic.co/t/how-to-add-new-gem-for-my-plugin-usage/68985) seems to imply this is the way to go, whereas [Logstash not finding installed gems](https://discuss.elastic.co/t/logstash-not-finding-installed-gems/74776) didn't even get an answer...

I am lost ...help!

---

<div class="post-metadata">

**Author:** ![uschtwill](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/uschtwill/32/14077_2.png) [@uschtwill](https://discuss.elastic.co/u/uschtwill)\
**Post date:** [March 25, 2017, 4:27pm UTC](https://discuss.elastic.co/t/installing-gem-for-ruby-filter-plugin/79994/2 "2017-03-25T16:27:47Z")

</div>

By the way, I got the idea on how to do this from here: [https://stackoverflow.com/questions/25984620/how-to-add-gems-into-logstash](https://stackoverflow.com/questions/25984620/how-to-add-gems-into-logstash), as I couldn't find any official documentation.

---

<div class="post-metadata">

**Author:** ![uschtwill](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/uschtwill/32/14077_2.png) [@uschtwill](https://discuss.elastic.co/u/uschtwill)\
**Post date:** [March 27, 2017, 8:47am UTC](https://discuss.elastic.co/t/installing-gem-for-ruby-filter-plugin/79994/3 "2017-03-27T08:47:34Z")

</div>

Anyone?

---

<div class="post-metadata">

**Author:** ![uschtwill](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/uschtwill/32/14077_2.png) [@uschtwill](https://discuss.elastic.co/u/uschtwill)\
**Post date:** [March 27, 2017, 1:38pm UTC](https://discuss.elastic.co/t/installing-gem-for-ruby-filter-plugin/79994/4 "2017-03-27T13:38:52Z")

</div>

_bump_

I am horribly stuck here...

---

<div class="post-metadata">

**Author:** ![uschtwill](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/uschtwill/32/14077_2.png) [@uschtwill](https://discuss.elastic.co/u/uschtwill)\
**Post date:** [March 28, 2017, 8:08am UTC](https://discuss.elastic.co/t/installing-gem-for-ruby-filter-plugin/79994/5 "2017-03-28T08:08:56Z")

</div>

At this point I am wondering: What does it mean that my question is drowning in others which all get replies? Is it silly? Is it stupid? Is it hard?

In case of the former, please educate me!

In case of the latter, and in the case that you don't feel like you can help me, maybe you know someone who could? If that is the case, I'd appreciate, if you could call that person's attention to this thread.

Cheers  
Will

---

<div class="post-metadata">

**Author:** ![uschtwill](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/uschtwill/32/14077_2.png) [@uschtwill](https://discuss.elastic.co/u/uschtwill)\
**Post date:** [March 29, 2017, 10:07am UTC](https://discuss.elastic.co/t/installing-gem-for-ruby-filter-plugin/79994/6 "2017-03-29T10:07:35Z")

</div>

Still stuck...

---

<div class="post-metadata">

**Author:** ![uschtwill](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/uschtwill/32/14077_2.png) [@uschtwill](https://discuss.elastic.co/u/uschtwill)\
**Post date:** [March 30, 2017, 8:13am UTC](https://discuss.elastic.co/t/installing-gem-for-ruby-filter-plugin/79994/7 "2017-03-30T08:13:49Z")

</div>

Should I provide more information?

---

<div class="post-metadata">

**Author:** ![uschtwill](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/uschtwill/32/14077_2.png) [@uschtwill](https://discuss.elastic.co/u/uschtwill)\
**Post date:** [March 30, 2017, 10:07am UTC](https://discuss.elastic.co/t/installing-gem-for-ruby-filter-plugin/79994/8 "2017-03-30T10:07:54Z")

</div>

[https://www.elastic.co/guide/en/logstash/current/plugins-filters-jdbc\_streaming.html](https://www.elastic.co/guide/en/logstash/current/plugins-filters-jdbc_streaming.html)

Neat, looks like I am one lucky guy! I will try that later!

On the other hand I would still like to find out how to add gems though... surely someone around here must know.

---

<div class="post-metadata">

**Author:** ![uschtwill](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/uschtwill/32/14077_2.png) [@uschtwill](https://discuss.elastic.co/u/uschtwill)\
**Post date:** [March 31, 2017, 3:33pm UTC](https://discuss.elastic.co/t/installing-gem-for-ruby-filter-plugin/79994/9 "2017-03-31T15:33:21Z")

</div>

I am a monkey.

While trying out different things, I must have at some point taken out the Dockerfile command to append the gem to the Gemfile. It's working now. Always. Investigate. Exception. Message.

An ashamed but happy monkey!

So, for completeness' sake and future generations:  
`RUN echo 'gem "jdbc-mysql"' >> Gemfile`  
... is what was missing.

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [March 31, 2017, 5:01pm UTC](https://discuss.elastic.co/t/installing-gem-for-ruby-filter-plugin/79994/10 "2017-03-31T17:01:50Z")

</div>

Let me know how you get on with the jdbc\_streaming. (I just wrote it, but I don't have a real personal use case and would appreciate feedback - especially regarding performance or memory consumption of the cache)

---

<div class="post-metadata">

**Author:** ![uschtwill](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/uschtwill/32/14077_2.png) [@uschtwill](https://discuss.elastic.co/u/uschtwill)\
**Post date:** [April 10, 2017, 10:57am UTC](https://discuss.elastic.co/t/installing-gem-for-ruby-filter-plugin/79994/11 "2017-04-10T10:57:23Z")

</div>

Hey @guyboertje, I did end up using the gem and connecting to the MySQL from within the Ruby filter after all. But should I start using the jdbc\_streaming at some point, I'll be more than happy to let you know how I do.

---

<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 8, 2017, 11:08am UTC](https://discuss.elastic.co/t/installing-gem-for-ruby-filter-plugin/79994/12 "2017-05-08T11:08:02Z")

</div>

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