Logstash require 'sqlite3'

When I run my logstash, error shown

no such file to load -- sqlite3

Is it because sqlite3 is not pre-installed with Logstash?
Is it possible to install sqlite3 for logstash?

gem install sqlite3

Reason being is that, I am required to access sqlite3 DB for some checking on certain fields.

Alternatively, I tried require 'sqlite3' at ruby init

ruby {
    init => "require 'sqlite3'"
    path => "./script.rb"
}

And it throw error message

Could not process event: uninitialized constant #Class:0x35324446::SQLite3

Thanks in advance.
Regards.

Hi @pohsun.teh,

you might need this guy -> Sqlite input plugin

More info -> Working with plugins

Hi, thanks for your reply.
I have the plugin installed, but from the example, isn't the plugin is for INPUT?

What I am trying to achieve is accessing sqlite on ruby script on FILTER part

Regards.

Could you describe a bit more what exactly you expect to happen?
What is the source data?
What do you want to do in the filter section?
What is the output?

I'm sorry if I'm not clear before.

To start, it would be normal input from json file.

Next at filter, I have ruby script to manipulate the data from input to only select fields I want

At the ruby script, I need to access sqlite to check on source and destination IP (I have a map of IP to name). Once I get the name, new field will be added before inserting to Elasticsearch

So, the problem I'm having now is accessing sqlite at ruby script.

Thanks.

I'm on very weak ice here so this is pure speculation. I don't know much Ruby...

I do not think Logstash needs to load the sqlite3 gem, so I would remove the init specification. I imagine the require 'sqlite3' goes in the .rb script.
I would also use a fully qualified path to the .rb script as I am not entirely sure what Logstash sees at the working path.

Without seeing the Ruby script it is hard (at least for me) to say anything more than that.

Well, I did try with require 'sqlite3' at .rb file. But it gives error.
On top of that, I wouldn't want my script to require sqlite at every event. So, that is the reason I require it at init

Thanks for your insight. Couldn't find anywhere regarding this matter. Only thing Logstash have with sqlite3 is the input plugin.

Got curious and found this on how to possibly add gem to Logstash.

Well, that's new.
From the looks of it, seems Logstash doesn't have easier way for gem install.

Thanks a lot for the link. Might give it a try.

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