在 Debian 上调试 Filebeat,通常可以从日志、配置测试、命令行调试、系统服务状态几个方面入手。下面按实用顺序说明。
systemctl status filebeat
如果没启动:
systemctl start filebeat
systemctl enable filebeat
Debian 上 Filebeat 默认日志位置:
journalctl -u filebeat -f
或查看日志文件(取决于配置):
/var/log/filebeat/filebeat
filebeat test config
输出类似:
Config OK
filebeat test output
filebeat -e -d "*"
说明:
-e:输出到 stderr(终端)-d "*":开启所有调试模块只调试某一部分:
filebeat -e -d "publish,registrar,input"
⚠️ 调试时建议先停掉 systemd 服务:
systemctl stop filebeat
编辑 /etc/filebeat/filebeat.yml:
logging.level: debug
logging.to_files: true
logging.files:
path: /var/log/filebeat
name: filebeat
keepfiles: 7
然后重启:
systemctl restart filebeat
Filebeat 记录读取位置:
/var/lib/filebeat/registry/filebeat/data.json
或旧版本:
/var/lib/filebeat/registry
确认:
harvester 调试filebeat -e -d "harvester,input"
重点看:
Start harvesterFile is inactiveSkipping fileFilebeat 用户通常无 root 权限:
ps aux | grep filebeat
确保:
/var/log/xxx.log
对 filebeat 用户可读。
filebeat.inputs:
- type: log
paths:
- /var/log/nginx/*.log
确认:
ls -l /var/log/nginx/
ignore_older: 24h
老文件不会读取。
filebeat test output
看:
filebeat.inputs:
- type: log
paths:
- /tmp/test.log
output.console:
pretty: true
logging.level: debug
运行:
filebeat -e -c /etc/filebeat/filebeat.yml
systemctl status filebeat
journalctl -u filebeat -f
filebeat test config
filebeat test output
filebeat -e -d "*"
如果你愿意,可以贴出:
/etc/filebeat/filebeat.ymljournalctl -u filebeat 报错日志我可以帮你精确分析。