在 Debian 上,Filebeat 转发日志通常有三种常见场景:
下面按最常见用法一步一步说明(以 Debian 11/12 为例)。
sudo apt update
sudo apt install filebeat -y
安装完成后配置文件在:
/etc/filebeat/filebeat.yml
编辑配置文件:
sudo vim /etc/filebeat/filebeat.yml
示例(监听系统日志):
filebeat.inputs:
- type: filestream
id: system-log
paths:
- /var/log/*.log
老版本可能是
type: log,Debian 新版推荐filestream
output.elasticsearch:
hosts: ["http://localhost:9200"]
username: "elastic"
password: "your_password"
启动:
sudo systemctl enable filebeat
sudo systemctl start filebeat
查看状态:
sudo systemctl status filebeat
output.logstash:
hosts: ["logstash.example.com:5044"]
Logstash 端需有:
input {
beats {
port => 5044
}
}
启动 Filebeat:
sudo systemctl restart filebeat
output.kafka:
hosts: ["kafka1:9092", "kafka2:9092"]
topic: "filebeat-logs"
例如系统日志模块:
sudo filebeat modules enable system
然后:
sudo filebeat setup
sudo filebeat test config
sudo filebeat test output
journalctl -u filebeat -f
filebeat.inputs:
- type: filestream
paths:
- /var/log/syslog
output.elasticsearch:
hosts: ["http://127.0.0.1:9200"]
如果你能告诉我:
我可以给你完全适配的配置文件。