Prerequisites
Before integrating Filebeat with Elasticsearch on Debian, ensure your system is updated (sudo apt update && sudo apt upgrade -y) and has Java installed (required for Elasticsearch). You’ll also need the Elastic APT repository for Filebeat/Elasticsearch installation.
1. Install Elasticsearch
Elasticsearch is the target data store for Filebeat. On Debian:
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt update && sudo apt install elasticsearch -y
/etc/elasticsearch/elasticsearch.yml to enable networking (set network.host: 0.0.0.0 and http.port: 9200).sudo systemctl start elasticsearch
sudo systemctl enable elasticsearch
curl -X GET "localhost:9200"
You should see a JSON response with cluster info.2. Install Filebeat
Filebeat is the lightweight shipper that forwards logs to Elasticsearch.
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt update && sudo apt install filebeat -y
sudo filebeat modules enable system
This configures Filebeat to monitor system logs (e.g., /var/log/syslog).3. Configure Filebeat for Elasticsearch Output
Edit Filebeat’s main config file (/etc/filebeat/filebeat.yml) to define the Elasticsearch output and log inputs:
Define Log Inputs: Specify which logs Filebeat should monitor. For system logs:
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log # Monitor all .log files in /var/log
- /var/log/syslog # Include syslog (optional)
Configure Elasticsearch Output: Replace localhost:9200 with your Elasticsearch host/IP. For unsecured clusters:
output.elasticsearch:
hosts: ["localhost:9200"]
index: "filebeat-%{[agent.version]}-%{+yyyy.MM.dd}" # Dynamic index name (e.g., filebeat-7.17.0-2025.09.24)
For secured clusters (enabled X-Pack security), add authentication and SSL:
output.elasticsearch:
hosts: ["https://localhost:9200"]
username: "elastic" # Default superuser (change in production)
password: "your_secure_password"
ssl.certificate_authorities: ["/etc/filebeat/certs/ca.crt"] # Path to CA cert (if using self-signed certs)
Optional: Load Kibana Dashboards (for visualization):
If you plan to use Kibana, configure the Kibana endpoint to load default dashboards:
setup.kibana:
host: "localhost:5601" # Kibana address
Run sudo filebeat setup after configuration to load dashboards.
4. Start and Enable Filebeat
sudo systemctl start filebeat
sudo systemctl enable filebeat
sudo systemctl status filebeat
Look for “active (running)” in the output.5. Verify Integration
filebeat-* indices):curl -X GET "localhost:9200/_cat/indices?v"
http://localhost:5601), go to Stack Management > Index Patterns, and create a pattern for filebeat-*. Then, navigate to Discover to view log data.6. Security Best Practices (Optional but Recommended)
/etc/elasticsearch/elasticsearch.yml to enable X-Pack security:xpack.security.enabled: true
Restart Elasticsearch and set passwords for built-in users:sudo systemctl restart elasticsearch
sudo /usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive
output.elasticsearch:
hosts: ["localhost:9200"]
api_key: "id:api_key_value" # Generate via Kibana or Elasticsearch API
By following these steps, you’ll successfully integrate Filebeat with Elasticsearch on Debian, enabling log collection, forwarding, and storage for analysis in Elasticsearch (and visualization in Kibana if configured).