在 Debian 上调试 Filebeat,一般从「日志、配置测试、运行模式、问题定位」几个方面入手。下面按实战流程给你一个清晰指南。
journalctl -u filebeat -f
查看历史日志:
journalctl -u filebeat --since "1 hour ago"
tail -f /var/log/filebeat/filebeat
filebeat test config -c /etc/filebeat/filebeat.yml
测试输出(如 Elasticsearch / Logstash):
filebeat test output
如果有错误,会直接提示哪一行配置有问题。
systemctl stop filebeat
filebeat -e -c /etc/filebeat/filebeat.yml -d "*"
常用 debug 模块:
-d "publish"
-d "registrar"
-d "harvester"
-d "input"
示例:
filebeat -e -c /etc/filebeat/filebeat.yml -d "harvester,publish"
-e:日志输出到终端
-d:开启 debug
filebeat -e -c /etc/filebeat/filebeat.yml -d "input"
cat /var/lib/filebeat/registry/filebeat/log.json | jq
或旧版本:
cat /var/lib/filebeat/registry | jq
ignore_older 忽略exclude_files 排除ps aux | grep filebeat
如果是 root 启动但文件属主是其他用户,注意:
processors:
- add_fields:
fields:
test: true
aa-status
monitoring.enabled: true
monitoring.elasticsearch:
hosts: ["http://localhost:9200"]
可在 Kibana → Stack Monitoring 中查看。
# 状态
systemctl status filebeat
# 配置测试
filebeat test config
filebeat test output
# 前台调试
filebeat -e -c /etc/filebeat/filebeat.yml -d "*"
# 日志
journalctl -u filebeat -f
如果你愿意,可以贴一下:
filebeat.yml 关键配置我可以帮你精准定位问题。