在 Debian 上排查 Filebeat 问题,一般按“服务状态 → 配置 → 日志 → 权限 → 输出”这个顺序来。下面是一套实用排错清单。
systemctl status filebeat
如果没有运行:
systemctl start filebeat
systemctl enable filebeat
查看是否开机启动:
systemctl is-enabled filebeat
Debian 下日志通常在:
journalctl -u filebeat -f
或:
tail -f /var/log/filebeat/filebeat
常见错误示例:
permission denied → 权限问题no such file or directory → 路径错误connection refused → 输出(Elasticsearch/Logstash)不可达filebeat test config
输出:
Config OK → 配置语法没问题filebeat test input
确认:
paths 是否正确Filebeat 通常以 filebeat 用户运行:
ps aux | grep filebeat
确保:
ls -l /var/log/xxx.log
如果日志文件权限不足:
chmod 644 /var/log/xxx.log
chown root:adm /var/log/xxx.log
⚠️ 注意:
chmod 755 /var/log
output.elasticsearch:
hosts: ["http://localhost:9200"]
测试连通性:
curl -X GET http://localhost:9200
output.logstash:
hosts: ["localhost:5044"]
测试端口:
telnet localhost 5044
# 或
nc -vz localhost 5044
编辑 /etc/filebeat/filebeat.yml:
logging.level: debug
logging.selectors: ["*"]
重启:
systemctl restart filebeat
查看详细日志:
journalctl -u filebeat -f
Filebeat 记录读取位置:
/var/lib/filebeat/registry
如果日志“不再更新”,可尝试(⚠️会重新读取):
systemctl stop filebeat
rm -rf /var/lib/filebeat/registry
systemctl start filebeat
| 问题 | 可能原因 |
|---|---|
| 收不到日志 | paths 写错 / 权限不足 |
| 日志重复 | registry 损坏 |
| 启动失败 | yml 缩进错误 |
| ES 拒绝 | 用户/密码/HTTPS |
| 磁盘暴涨 | debug 日志没关 |
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/syslog
output.elasticsearch:
hosts: ["http://localhost:9200"]
如果你愿意,可以把:
filebeat.ymljournalctl -u filebeat 报错贴出来,我可以直接帮你定位具体问题。