在 Debian 上 Filebeat 报错 是很常见的问题,但“报错”本身信息太宽。我给你一个系统性的排查思路和常见错误解决方案,你对照看看是哪一类。
先执行:
sudo systemctl status filebeat
sudo journalctl -u filebeat -n 100 --no-pager
或者前台运行看详细错误:
sudo filebeat -e -c /etc/filebeat/filebeat.yml
把红色 ERROR 行记下来,这是定位关键。
典型报错:
YAML config parsing failed
解决:
sudo filebeat test config
常见原因:
-✅ 建议用 2 个空格缩进,不要用 Tab。
典型报错:
connection attempt failed
Cannot connect to host
解决:
output.elasticsearch:
hosts: ["http://localhost:9200"]
curl -v http://localhost:9200
output.elasticsearch:
username: "elastic"
password: "xxxx"
典型报错:
open /var/log/xxx.log: permission denied
解决:
sudo usermod -aG adm filebeat
sudo systemctl restart filebeat
或确认日志文件权限:
ls -l /var/log/xxx.log
典型报错:
module not found
解决:
sudo filebeat modules enable system nginx
sudo filebeat setup
检查:
sudo filebeat test output
确认:
exclude_files 排除sudo filebeat test config
sudo filebeat test output
sudo systemctl restart filebeat
sudo journalctl -u filebeat -f
你可以直接把 报错原文贴出来(红色 ERROR 那几行),我可以:
filebeat.yml你现在是 Filebeat → ES 还是 Filebeat → Logstash?