How to Use Filebeat

Introduction Filebeat is a lightweight, open-source log shipper designed to efficiently collect, parse, and forward log data from various sources to centralized systems like Elasticsearch or Logstash. As part of the Elastic Stack, Filebeat plays a crucial role in ensuring seamless log management, monitoring, and analysis for IT operations, security teams, and developers. Understanding how to use F

Nov 17, 2025 - 11:07
Nov 17, 2025 - 11:07
 3

Introduction

Filebeat is a lightweight, open-source log shipper designed to efficiently collect, parse, and forward log data from various sources to centralized systems like Elasticsearch or Logstash. As part of the Elastic Stack, Filebeat plays a crucial role in ensuring seamless log management, monitoring, and analysis for IT operations, security teams, and developers. Understanding how to use Filebeat effectively can significantly enhance your organization's ability to monitor infrastructure, detect anomalies, and troubleshoot issues in real time.

This comprehensive tutorial will guide you through the essentials of using Filebeat. From installation and configuration to best practices and real-world examples, you will gain the knowledge required to leverage Filebeat for robust log management and observability.

Step-by-Step Guide

Step 1: Installing Filebeat

Filebeat is compatible with various operating systems including Linux, Windows, and macOS. The installation method depends on your environment.

On Linux (Debian/Ubuntu):

1. Download and install the Elastic GPG key:

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

2. Add the Elastic repository:

sudo apt-get install apt-transport-https

echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list

3. Update and install Filebeat:

sudo apt-get update && sudo apt-get install filebeat

On Windows:

1. Download the Filebeat zip archive from the Elastic downloads page.

2. Extract the archive to a folder, e.g., C:\Program Files\Filebeat.

3. Run Filebeat from the command line or install it as a Windows service using PowerShell.

Step 2: Configuring Filebeat

The primary configuration file is filebeat.yml. Key sections include inputs, outputs, and modules.

Configuring Inputs:

Inputs define what log files Filebeat should monitor. A simple example to monitor system logs:

filebeat.inputs:

- type: log

enabled: true

paths:

- /var/log/syslog

- /var/log/auth.log

Configuring Outputs:

Filebeat can send data directly to Elasticsearch or via Logstash.

Example for Elasticsearch output:

output.elasticsearch:

hosts: ["localhost:9200"]

Example for Logstash output:

output.logstash:

hosts: ["localhost:5044"]

Step 3: Using Filebeat Modules

Filebeat modules simplify the collection, parsing, and visualization of common log formats such as Apache, Nginx, MySQL, and system logs.

To enable a module, use the command:

filebeat modules enable apache

Then, configure the module if necessary in /etc/filebeat/modules.d/apache.yml.

Load ingest pipelines and dashboards with:

filebeat setup --pipelines --dashboards

Step 4: Starting and Managing Filebeat

After configuration, start Filebeat:

On Linux:

sudo systemctl start filebeat

Enable it to start on boot:

sudo systemctl enable filebeat

On Windows:

Run as a service or start via command prompt:

Start-Service filebeat

Step 5: Verifying Filebeat Operation

Check logs to verify proper startup and operation:

sudo journalctl -u filebeat -f

Or check the log file at /var/log/filebeat/filebeat.

Test if data is reaching Elasticsearch by querying indices:

curl -X GET "localhost:9200/filebeat-*/_search?pretty"

Best Practices

1. Use Filebeat Modules When Possible

Modules provide prebuilt configurations and ingest pipelines optimized for common log types. This reduces manual parsing errors and speeds up deployment.

2. Keep Filebeat Lightweight

Filebeat is designed to be lightweight. Avoid adding complex processing logic in Filebeat; delegate heavy parsing and enrichment to Logstash or Elasticsearch ingest nodes.

3. Secure Your Data Transport

Use TLS encryption between Filebeat and output services like Elasticsearch or Logstash to protect sensitive log data during transmission.

4. Monitor Filebeat Health

Implement monitoring for Filebeat processes and metrics. Elastic Stack provides monitoring features that can alert on drops or failures in log shipping.

5. Manage Log Rotation and Retention

Ensure your input log files are rotated and archived to prevent Filebeat from endlessly reading huge files. Configure close_inactive and clean_inactive settings wisely.

Tools and Resources

Elastic Official Documentation

The most authoritative source for Filebeat is Elastics official documentation available at elastic.co. It includes detailed guides, configuration references, and troubleshooting tips.

Elastic Stack Components

Filebeat integrates seamlessly with Logstash, Elasticsearch, and Kibana. Understanding these tools will help you build a complete logging pipeline.

Community Forums and GitHub

Elastics community forums and GitHub repositories are valuable for community-driven support, examples, and custom modules.

Configuration Analyzers

Tools like Configbeat help verify Filebeat configuration syntax and best practices.

Real Examples

Example 1: Shipping Apache Logs to Elasticsearch

This example demonstrates enabling the Apache module to collect logs and send them directly to Elasticsearch.

filebeat modules enable apache

filebeat setup --pipelines --dashboards

Start Filebeat service

sudo systemctl start filebeat

After this, Apache logs are parsed and indexed in Elasticsearch, and default Kibana dashboards become available for visualization.

Example 2: Custom Log File Monitoring

Suppose you want to monitor a custom application log located at /var/log/myapp/app.log. Configure Filebeat input as:

filebeat.inputs:

- type: log

enabled: true

paths:

- /var/log/myapp/app.log

multiline.pattern: '^\['

multiline.negate: true

multiline.match: after

This configuration handles multiline log entries that start with a square bracket, commonly used in timestamps.

Example 3: Sending Logs to Logstash with TLS

output.logstash:

hosts: ["logstash.example.com:5044"]

ssl.enabled: true

ssl.certificate_authorities: ["/etc/pki/tls/certs/logstash-ca.pem"]

This setup ensures secure transmission of logs to Logstash over TLS.

FAQs

What is the difference between Filebeat and Logstash?

Filebeat is a lightweight log shipper designed to forward logs with minimal processing. Logstash is a more robust data processing pipeline capable of complex parsing, enrichment, and routing. Filebeat typically forwards data to Logstash or Elasticsearch.

Can Filebeat handle multiline logs?

Yes, Filebeat supports multiline log processing using the multiline configuration options, which allow grouping multiple lines into a single event, such as stack traces.

Is Filebeat resource-intensive?

No, Filebeat is designed to be lightweight and efficient, making it suitable for deployment on production servers without significant performance impact.

How do I update Filebeat safely?

Stop the Filebeat service, update the package using your systems package manager, verify configuration compatibility, and restart the service. Always test updates in a staging environment.

Can Filebeat send data to multiple outputs?

Filebeat supports a single output configuration at a time. To send data to multiple destinations, consider using Logstash or Elasticsearch ingest pipelines for further routing.

Conclusion

Filebeat is an essential component in modern log management and observability architectures. Its lightweight design, modular capabilities, and seamless integration with the Elastic Stack make it a powerful tool for collecting and shipping logs efficiently. By following this detailed tutorial, you should be well-equipped to install, configure, and optimize Filebeat for your specific needs.

Implementing best practices such as using modules, securing transport, and monitoring Filebeats health will ensure reliable log collection and enhance your organization's ability to respond to operational and security events swiftly. Leverage the abundant resources available and experiment with real-world configurations to unlock the full potential of Filebeat.