Filebeat Basics
Let's learn about Filebeat
Reference: filebeat docs
What is Filebeat?
Filebeat
A lightweight
Producerfor forwarding and centralizing log dataFilebeat, installed as an agent on the server,Monitors a directory or specific files,
Collects log events, and
Forwards them to
ElasticsearchorLogstashfor indexing
How it works?
When Filebeat starts, it has one or more prospectors watching the log data specified in the configuration
Each time an event occurs in the specified log file,
Filebeatstarts a data harvesterEach harvester watching a single log file reads new log data and sends it to
libbeatlibbeataggregates events and sends the aggregated data to the output configured in theFilebeatsettings
How Filebeat works (in detail)
Filebeat is composed of
prospectorsandharvestersThese two components work together to track files and forward event data to the specified destination
What is a harvester?
harvester?A Harvester is responsible for reading the contents of a file
It reads each file line by line and sends the contents
One Harvester starts and finishes work per file
That is, while the Harvester is running, the file descriptor is open and the harvester continuously reads the file
ConsThere is a disadvantage of occupying disk space until the harvester finishes its work!
What is a prospector?
prospector?A Prospector is responsible for managing harvesters and finding resources to read
If the
inputis log, the prospector:Finds all files in the corresponding path and
Runs a harvester on each file
An example of configuring
Filebeatto read all log files from specified paths:ex)
Filebeat currently supports
logandstdinas prospector typesFilebeat prospectors can only read local files!
They cannot connect to a remote host to read files or logs!!
How does Filebeat keep the state of files?
Filebeat tracks the state of each file and saves it to a registry file on disk
The state is used to:
Remember where the harvester was last reading, and
Guarantee that all logs have been sent
While Filebeat is running, state information is stored in memory by the
prospectorWhen Filebeat restarts:
The information stored in the registry file is used to reset the state, and
Filebeat runs each
harvesterfrom the position where it was last executing
Last updated