在 Debian 上调试 Filebeat,通常可以从日志、配置校验、调试模式、系统服务状态几个方面入手。下面按实用顺序说明。
systemctl status filebeat
若未运行:
systemctl start filebeat
systemctl enable filebeat
ps aux | grep filebeat
journalctl -u filebeat -f
或查看日志文件(取决于配置):
/var/log/filebeat/filebeat
常见错误:
no such file or directory(路径错误)connection refused(Elasticsearch/Logstash 连不上)permission denied(无读权限)filebeat test config
filebeat test output
先停止服务:
systemctl stop filebeat
然后:
filebeat -e -d "*" -c /etc/filebeat/filebeat.yml
参数说明:
-e:输出到终端-d "*":开启所有调试-c:指定配置文件在 filebeat.yml 中:
logging.level: debug
logging.to_files: true
logging.files:
path: /var/log/filebeat
name: filebeat
keepfiles: 7
修改后:
systemctl restart filebeat
filebeat registry list /var/lib/filebeat/registry
(旧版本可能是 registry.json)
ls -l /var/log/xxx.log
Filebeat 用户需有读权限:
getent passwd filebeat
curl -X GET "localhost:9200/_cat/indices?v"
查看 Logstash 日志:
journalctl -u logstash -f
| 问题 | 排查 |
|---|---|
| 无数据 | filebeat test input |
| 权限问题 | sudo -u filebeat cat /var/log/xxx.log |
| YAML 错误 | filebeat test config |
| 时间不对 | 检查 UTC 与 local |
| 多次重复采集 | registry 被清 |
如果你愿意,可以贴出:
filebeat.yml我可以帮你精准定位问题。