Ruby Scripts in Logstash CONF file


#1

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.


(Magnus Bäck) #2

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.


#3

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 !


(Magnus Bäck) #4

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


#5

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:

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 !


(Magnus Bäck) #6

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


#7

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:

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 !


(system) #8

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