在 Debian 上调试 Filebeat,一般可以从 状态检查、日志、配置测试、调试模式、系统服务 几个方面入手。下面按实用顺序给你一套排查思路。
systemctl status filebeat
或(老版本):
service filebeat status
查看是否 active (running)
如果没运行:
journalctl -u filebeat -xe
journalctl -u filebeat -f
默认路径:
/var/log/filebeat/filebeat
查看错误:
tail -n 100 /var/log/filebeat/filebeat
filebeat test config
✅ 输出 Config OK 表示语法没问题
filebeat test output
示例正常输出:
elasticsearch: https://localhost:9200...
parse url... OK
connection... OK
filebeat -e -d "*"
参数说明:
-e:输出到 stderr-d "*":开启所有 debug 模块只看某个模块:
filebeat -e -d "publish,registrar,input"
ls -l /var/lib/filebeat/registry/
或(新版本):
/var/lib/filebeat/registry/filebeat/log.json
如果文件 没出现在 registry,说明:
Filebeat 默认以 root 或 filebeat 用户运行:
ps aux | grep filebeat
确保对日志文件有读权限:
ls -l /var/log/xxx.log
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/nginx/*.log
常见错误:
enabled: falseoutput.elasticsearch:
hosts: ["https://localhost:9200"]
username: "elastic"
password: "xxx"
output.logstash:
hosts: ["localhost:5044"]
⚠️ 注意:
| 问题 | 可能原因 |
|---|---|
| 无数据 | input 未 enable |
| 连不上 ES | 证书 / 账号错误 |
| 文件不读 | 权限 / 路径 |
| 数据重复 | registry 损坏 |
| CPU 高 | debug 模式未关 |
systemctl stop filebeat
rm -rf /var/lib/filebeat/registry
systemctl start filebeat
如果你愿意,可以贴出:
filebeat.yml我可以帮你精确定位问题。