在 Debian 系统上调试 Filebeat,一般可以从 状态检查、日志、配置验证、调试模式、数据流向 这几个层面入手。下面给你一套比较完整的调试思路。
systemctl status filebeat
如果未启动:
systemctl start filebeat
systemctl enable filebeat
ps aux | grep filebeat
journalctl -u filebeat -f
默认路径:
/var/log/filebeat/filebeat
或者:
ls /var/log/filebeat/
查看最近日志:
tail -f /var/log/filebeat/filebeat
filebeat test config
常见错误:
: 或 -filebeat test output
常见失败原因:
filebeat -e -d "*"
常用参数:
-e:输出到标准错误-d "*":开启所有调试-d "publish":只调试数据发送-d "files":只调试文件采集示例:
filebeat -e -d "files,publish"
filebeat -e -v
ls /var/lib/filebeat/registry/
如果文件没有被采集,常见原因:
在 filebeat.yml 中:
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/test.log
ignore_older: 0
output.console:
pretty: true
然后运行:
filebeat -e
如果能看到 JSON 输出,说明采集没问题,问题在输出侧。
output.elasticsearch:
hosts: ["http://localhost:9200"]
username: "elastic"
password: "xxx"
chmod 644 /var/log/xxx.log
或:
usermod -aG adm filebeat
systemctl restart filebeat
检查:
include_lines / exclude_lines 是否误过滤确认:
curl -X GET "localhost:9200/_cat/indices?v"
systemctl status filebeatjournalctl -u filebeat -ffilebeat test configfilebeat test outputfilebeat -e -d "*"output.console 验证采集如果你愿意,可以把下面信息贴出来,我可以帮你精准定位:
filebeat.yml 相关配置