Logstash: How To Install A Plugin- The Simplest Ways.

Photo by cottonbro from Pexels

Logstash, one of the key tools of the ELK stack has been gaining a lot of popularity in the last couple of years. In this tutorial, we’ll go through the two ways to install a plugin on Logstash.

First up, we have to know exactly which plugin we’re going to install. Logstash has got four (04) types of plugins: input plugins, filter plugins, output plugins, and codec plugins. As we talked about in a previous article, there are tons of tons of Logstash plugins. They are written in Ruby and are available either as gem packages on https://rubygems.org/ or on https://github.com/logstash-plugins.

Now that we’ll are sunk into Logstash plugins word, let’s get started.

1- Install a plugin from the internet

The first thing we’re going to do will be to find the installation directory of Logstash on our machine.

Run this command if you’re on Ubuntu:

Check each one of the paths you’ve got and look for a bin folder for the path we’re looking for. On Ubuntu, the right path is /usr/share/logstash as default path.

So let’s move to that folder.

We’re now ready to install our plugin. The plugin I’m going to install is logstash-input-rabbitmq.

After few minutes, you’re ready to check if your plugin is well installed. Let’s do that.

This should prompt your newly installed plugin at the end of the output content in your terminal. Now without too much talk, let’s get into the manual installation

2- Install a plugin offline — from Github.com

The first time I came across this possibility, I asked myself why engineers are going to install a Logstash plugin offline. The truth is that there are a lot of private network Logstash deployments without network access.

For offline installation, there are two ways to proceed. But for both of them, we’ll need a machine with internet access.

On your machine that is connected to the internet, go through these steps.

Then move into the cloned folder.

Then we’re going to build the plugin gem. In order to do that, we need the Ruby bundler. Let’s go ahead and install it.

On Ubuntu, execute this command:

Now we’re good to go. Let’s build our plugin. The file we’re interested in is the .gemspec file.

We’re almost done. Now we need to move the cloned folder to our offline machine.

On your machine offline machine, go through these steps.

Move to your Logstash installation directory. On Ubuntu, the default path is /usr/share/logstash.

Open your Gemfile

Add this line:

My full path is: /var/lib/logstash/plugins/logstash-input-rabbitmq.

Do you feel like you want to give up? Hold on. These are the final steps 🥁.

Now run:

Let’s check if everything went well.

🛑 Don’t forget to replace your plugin name everywhere I used bold text for the terminal commands!

You should get back the name of your fresh install Logstash plugin.

Logstash is an amazing tool. Its tons of plugins make it just wonderful to use. Thank you’ll guys for following along.

In the following article, we’ll be working on a very interesting project proposed to me by Nidhi.

Till next time, take care.