Beats are small programs that collect data from your computers and send it to Elasticsearch. Filebeat collects log files, and Metricbeat collects system metrics like CPU and memory.
You want to watch log files from your web server to find errors.
You need to track how much CPU and memory your servers use over time.
You want to send data from many computers to one place for easy searching.
You want to monitor your applications and systems without installing heavy software.
You want to quickly set up data collection for your Elasticsearch dashboards.
Example Metricbeat config to collect CPU and memory metrics every 10 seconds.
Elasticsearch
metricbeat.yml
metricbeat.modules:
- module: system
metricsets:
- cpu
- memory
period: 10s
output.elasticsearch:
hosts: ["localhost:9200"]
Sample Program
This example shows a basic Filebeat setup to send system logs to Elasticsearch. The comments explain how to run it and what output to expect.
Elasticsearch
# This is a simple Filebeat config example
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/syslog
output.elasticsearch:
hosts: ["localhost:9200"]
# To run Filebeat:# 1. Save this as filebeat.yml# 2. Run 'filebeat setup' to prepare Elasticsearch# 3. Run 'filebeat -e' to start sending logs# Output example when running 'filebeat -e':# 2024-06-01T12:00:00.000Z INFO instance/beat.go:123 Setup Beat: filebeat; Version: 8.0.0# 2024-06-01T12:00:01.000Z INFO crawler/crawler.go:75 Loading and starting input: log# 2024-06-01T12:00:02.000Z INFO pipeline/output.go:95 Connecting to backoff(elasticsearch(http://localhost:9200))# 2024-06-01T12:00:03.000Z INFO pipeline/output.go:105 Connection to backoff(elasticsearch(http://localhost:9200)) established# 2024-06-01T12:00:04.000Z INFO crawler/crawler.go:95 Input started: log
OutputSuccess
Important Notes
Beats are lightweight and easy to install on many machines.
Always run setup commands before starting Beats to prepare Elasticsearch.
Use the -e flag to run Beats in the foreground and see logs directly.
Summary
Beats collect data like logs and metrics from your computers.
Filebeat is for logs; Metricbeat is for system metrics.
They send data to Elasticsearch for easy searching and monitoring.
Practice
(1/5)
1. What is the primary purpose of Filebeat in the Elastic Stack?
easy
A. To visualize data in dashboards
B. To collect system metrics like CPU and memory usage
C. To collect and ship log files from servers
D. To store data in Elasticsearch
Solution
Step 1: Understand Filebeat's role
Filebeat is designed to collect log files from servers and forward them.
Step 2: Differentiate from Metricbeat
Metricbeat collects system metrics, not logs.
Final Answer:
To collect and ship log files from servers -> Option C
Quick Check:
Filebeat = log collection [OK]
Hint: Filebeat = logs, Metricbeat = metrics [OK]
Common Mistakes:
Confusing Filebeat with Metricbeat
Thinking Filebeat visualizes data
Assuming Filebeat stores data
2. Which of the following is the correct syntax to start Filebeat on a Linux system?
easy
A. sudo systemctl start filebeat
B. filebeat run start
C. start filebeat service
D. service filebeat enable
Solution
Step 1: Identify standard Linux service start command
On modern Linux systems, services are started with 'sudo systemctl start servicename'.
Step 2: Match with Filebeat service
Filebeat service is named 'filebeat', so the command is 'sudo systemctl start filebeat'.
Final Answer:
sudo systemctl start filebeat -> Option A
Quick Check:
systemctl start filebeat = correct syntax [OK]
Hint: Use systemctl to manage services on Linux [OK]