doveFluent Bit – Sending Logs to ELK with Fluent Bit.

In this section, we will install Fluent Bit on a Windows machine to read logs from a file, parse the logs to extract relevant fields, and forward them to an Elasticsearch running on an Ubuntu machine.

Fluent Bit

Fluent Bit is a lightweight and high-performance log processor and forwarder. It is commonly used to collect, process, and ship logs to various destinations, such as Elasticsearch.

Installing and Configuring Fluent Bit on Windows

  1. Download it from the official websitearrow-up-right, download the appropriate file for your Windows machine.

  1. Extract the contents of the ZIP file to C:\Program Files\fluent-bit

  1. Now, let's take a look at the sample logs file we want to parse

  1. We will use Rubular arrow-up-rightto ensure the appropriate regex pattern

  • There is an unmatched line. Looking closely, this happened because that log has some unique attributes: TYPE CODE ID ,We can make another regex pattern to match it.

  1. Now we will update the parsers.conf file, which located at C:\Program Files\Fluent-bit\conf , to add the two parsers we made previously

circle-info

If you don't have permission to save changes in the file in that path, you can save it in another path, delete the unupdated one, and move the updated file after to replace it.

  1. Next we will update the fluent-bit.conf , which is located at the same previous path. But before we start editing, we need to know the 3 main sections we will focus on.

  • [INPUT]: Specifies where logs are collected from; in our case, it will be collected from the sample logs file we have created.

  • [OUTPUT]: Specifies where logs should be sent; we want to forward them to Elasticsearch.

  • [PARSER]: Defines how logs should be structured using regex; we have updated the parser.conf file so there is no need to change it.

  • The input name tail is an input plugin that allows to monitor one or several text files. It has a similar behavior to the tail -f shell command.

  • The plugin reads every matched file in the Path pattern and for every new line found (separated by a newline character (\n) ), so we will duplicate some logs in the file to generate new records

  • We have configured two outputs: es is the Elasticsearch and stdout will prints to our running shell

  • tls : on , tls.verify : off Those are important if Elasticsearch is configured with https

  1. Now we will run the Fluent-bit

circle-info

The & operator tells PowerShell explicitly to treat the string as an executable

  1. Open Elasticsearch and navigate to index management to ensure the existence of fluent-bit

  1. Start to duplicate some data in the network_sample.txt, then go to discover in Elasticsearch and create a data view to the fluent-bit

We're done! Fluent Bit reads some logs, parses them using regex, and forwards the structured data to Elasticsearch.

Last updated