下面给你一份在 Debian 上调试 Filebeat 的实用思路,从“最常用”到“进阶”,基本能覆盖 90% 的问题场景。
systemctl status filebeat
如果没启动:
systemctl start filebeat
开机自启:
systemctl enable filebeat
停止服务后前台运行,可以看到实时日志和错误:
systemctl stop filebeat
filebeat -e -d "*" -c /etc/filebeat/filebeat.yml
常用参数说明:
-e:把日志输出到 stderr(终端)-d "*":开启所有 debug-c:指定配置文件⚠️ 调试完记得重新启动服务:
systemctl start filebeat
Debian 上日志一般在:
journalctl -u filebeat -f
或旧版本:
tail -f /var/log/filebeat/filebeat
在 filebeat.yml 中:
logging.level: debug
logging.to_files: true
logging.files:
path: /var/log/filebeat
name: filebeat
keepfiles: 7
然后重启:
systemctl restart filebeat
filebeat test config
filebeat test output
示例:
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/nginx/*.log
filebeat test output
常见错误:
确认:
Filebeat 用 registry 记录文件读取位置:
ls -l /var/lib/filebeat/registry/
如果怀疑“文件不采集”:
systemctl stop filebeat
rm -rf /var/lib/filebeat/registry
systemctl start filebeat
| 问题 | 可能原因 |
|---|---|
| 没有日志输出 | input 路径错误 |
| 权限 denied | filebeat 用户无读权限 |
| ES 收不到 | output 配置或证书问题 |
| 日志重复 | registry 损坏 |
| CPU 高 | 通配符过大或 debug 开着 |
systemctl stop filebeat
filebeat -e -d "publish,input,output"
如果你愿意,可以:
我可以直接帮你定位问题。