Getting started with Filebeat

How to analyze log files using Filebeat and Elasticsearch

vikas yadav
DevOps Dudes
5 min readJul 31, 2021

--

Photo by Lewis Kang'ethe Ngugi on Unsplash

Inspecting and analyzing system log files are a part and parcel of every IT system administrator’s day. A centralized logging system makes life easier for IT admins and helps identify and fix faults more efficiently, ELK stack can help you store your logging data centrally and analyze your log files.

In the previous articles, I gave an overview of the elastic stack and installed an elastic search on Linux. In this article, I’ll focus on Filebeat.

Filebeat is a light weight log shipper which is installed as an agent on your servers and monitors the log files or locations that you specify, collects log events, and forwards them either to Elasticsearch or log stash for indexing

Filebeat has two components

  1. Harvester — A harvester is responsible for reading the content of a single file. The harvester reads each file, line by line, and sends the content to the output.
  2. Input — An input is responsible for managing the harvesters and finding all sources to read from

How Filebeat works

  1. It starts with one or more inputs that look in the locations you’ve specified for log data.
  2. For each log that Filebeat locates, it starts a harvester.
  3. Each harvester reads a single log for new content and sends the new log data to libbeat,
  4. Libbeat aggregates the events and sends the aggregated data to the output that you’ve configured for File beat.

Lab Setup

In this article, I’ll set up a single-node elastic search cluster(refer to this article) and two apache webservers. I have used the GCP platform to build my test lab since it offers $300 USD free trial credit but you can do it on your servers or any other public cloud platform as well.

Filebeat Installation

Note: You’ll need an existing elastic search cluster to store log data and Kibana to visualize this data. We will also need metric beat installed on this server.

  1. Please read this article to help set up a single-node elastic search instance and Kibana.
  2. Please read this article to help set up the metric beat.

We’ll use the APT repository method to install Filebeat.

Installation and configuration of Filebeat on ELK Server

Minimum software requirements for Filebeat installation on ELK server should already be met as we already have elastic search and Metricbeat installed on this server.

1. Validate logging configuration

To start with out file beat setup, we need to first validate that logging is correctly setup for various components of our lab

1.1 Elasticsearch

1.2 Kibana

1.2.1 configure Kibana logging

1.2.2 Create log file for Kibana

1.2.3 configure logging for Metricbeat

1.2. Restart service for changes to take effect

2. Install Filebeat

3. Configure Filebeat

4. Enable beat-pack if not already enabled

5. Configure beat-expack

6. Validate Metricbeat service is running

7. Start Filebeat

8. Enable modules

With our ELK server setup with Filebeat, it is time to move on to our webservers.

Installation and configuration of Filebeat on Web Servers

1. Download and install the public signing key

2. Install apt-transport-https package

3. Save directory definitions

4. System Update

5. Validate logging is configured for Metricbeat

6. Restart service for changes to take effect

7. Install Filebeat

8. Configure Filebeat

9. Enable beat-pack if not already enabled

10. configure beat-expack

11. Validate Metricbeat service is running

## 12. start Filebeat

13. Enable modules

14. Stack monitoring

You can view if your beats are set up correctly under the stack monitoring, you should now be able to see Filebeat listed under your beats

If you click on a beat and select one of the servers, you should be able to see some more statistics

15. Dashboards

If your system is set up correctly , you should be able to see a dashboard just like this one

ou

So, here’s how you can configure Filebeat to store your logging data centrally.

If you want to do some hands-on practice on Elaticsearch, here is the link to my youtube playlist where I show you how to can set up a lab setup with 2 apache servers feeding data to a single-node Elasticsearch cluster deployed on a google cloud platform or GCP.

--

--

vikas yadav
DevOps Dudes

IT engineer with 14 years of experience in IT with recent experience in Solution design, Big data, and log analytics.