下面按常见场景给你说明在 Debian 上如何启动 Filebeat(假设你已经安装好了)。
filebeat version
如果提示命令不存在,先安装:
sudo apt update
sudo apt install filebeat
编辑配置文件:
sudo nano /etc/filebeat/filebeat.yml
最基础示例(输出到 Elasticsearch):
filebeat.inputs:
- type: log
paths:
- /var/log/*.log
output.elasticsearch:
hosts: ["localhost:9200"]
或输出到 Logstash:
output.logstash:
hosts: ["localhost:5044"]
测试配置是否正确:
sudo filebeat test config
sudo filebeat test output
sudo filebeat setup
sudo systemctl start filebeat
sudo systemctl enable filebeat
sudo systemctl status filebeat
journalctl -u filebeat -f
sudo filebeat -e -c /etc/filebeat/filebeat.yml
按 Ctrl+C 停止。
✅ 启动失败常见原因:
filebeat.yml 格式错误(缩进必须是空格)如果你告诉我:
我可以给你更精确的配置示例。