Installing Logstash (Optional)edit

The simplest architecture for the Beats platform setup consists of one or more Beats, Elasticsearch, and Kibana. This architecture is easy to get started with and sufficient for networks with low traffic. It also uses the minimum amount of servers: a single machine running Elasticsearch and Kibana. The Beats insert the transactions directly into the Elasticsearch instance.

If you want to perform additional processing or buffering on the data, however, you’ll want to install Logstash.

An important advantage to this approach is that you can use Logstash to modify the data captured by Beats in any way you like. You can also use Logstash’s many output plugins to integrate with other systems.

To download and install Logstash, use the commands that work with your system:

deb:

sudo apt-get install openjdk-8-jre
curl -L -O https://artifacts.elastic.co/downloads/logstash/logstash-5.2.2.deb
sudo dpkg -i logstash-5.2.2.deb

rpm:

sudo yum install java-1.8.0-openjdk
curl -L -O https://artifacts.elastic.co/downloads/logstash/logstash-5.2.2.rpm
sudo rpm -i logstash-5.2.2.rpm

mac:

# install Java, e.g. from: https://www.java.com/en/download/manual.jsp
curl -L -O https://artifacts.elastic.co/downloads/logstash/logstash-5.2.2.zip
unzip logstash-5.2.2.zip

win:

  1. If necessary, download and install the latest version of the Java from www.java.com.
  2. Download the Logstash 5.2.2 Windows zip file from the downloads page.
  3. Extract the contents of the zip file to a directory on your computer, for example, C:\Program Files.

Don’t start Logstash yet. You need to set a couple of configuration options first.

Setting Up Logstashedit

In this setup, the Beat sends events to Logstash. Logstash receives these events by using the Beats input plugin for Logstash and then sends the transaction to Elasticsearch by using the Elasticsearch output plugin for Logstash. The Elasticsearch output plugin uses the bulk API, making indexing very efficient.

To set up Logstash:

  1. Make sure you have the latest compatible version of the Beats input plugin for Logstash installed.

    The Beats input plugin requires Logstash 1.5.4 or later. If you are using Logstash 1.5.4, you must install the Beats input plugin before applying this configuration because the plugin is not shipped with 1.5.4.

    To install the required plugin, run the following command inside the logstash directory (for deb and rpm installs, the directory is /opt/logstash).

    deb, rpm, and mac:

    ./bin/logstash-plugin install logstash-input-beats

    win:

    bin\logstash-plugin install logstash-input-beats
  2. Configure Logstash to listen on port 5044 for incoming Beats connections and to index into Elasticsearch. You configure Logstash by creating a configuration file. For example, you can save the following example configuration to a file called logstash.conf:

    input {
      beats {
        port => 5044
      }
    }
    
    output {
      elasticsearch {
        hosts => "localhost:9200"
        manage_template => false
        index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
        document_type => "%{[@metadata][type]}"
      }
    }

    Logstash uses this configuration to index events in Elasticsearch in the same way that the Beat would, but you get additional buffering and other capabilities provided by Logstash.

To use this setup, you’ll also need to configure your Beat to use Logstash. For more information, see the documentation for the Beat.

Updating the Beats Input Plugin for Logstashedit

Plugins have their own release cycle and are often released independent of Logstash’s core release cycle. To ensure that you have the latest version of the Beats input plugin for Logstash, run the following command from your Logstash installation:

deb, rpm, and mac:

./bin/logstash-plugin update logstash-input-beats

win:

bin\logstash-plugin update logstash-input-beats

Keep in mind that you can update to the latest version of the plugin without having to upgrade to a newer version of Logstash. More details about working with input plugins in Logstash are available here.

Starting Logstashedit

Now you can start Logstash. Use the command that works with your system. If you installed Logstash as a deb or rpm package, make sure the config file is in the expected directory.

deb:

sudo /etc/init.d/logstash start

rpm:

sudo service logstash start

mac:

./bin/logstash -f logstash.conf

win:

bin\logstash.bat -f logstash.conf
Note

The default configuration for Beats and Logstash uses plain TCP. For encryption you must explicitly enable SSL when you configure Beats and Logstash.

You can learn more about installing, configuring, and running Logstash here.