在 CentOS 上使用 Filebeat 时,排错一般遵循“先看状态 → 再看日志 → 再查配置 → 最后验证链路”的思路。下面给你一套实用排错清单。
systemctl status filebeat
常见状态:
active (running):正常failed:启动失败(看日志)手动启动看报错:
filebeat -e -c /etc/filebeat/filebeat.yml
(-e 直接输出到终端,方便看错误)
journalctl -u filebeat -f
tail -f /var/log/filebeat/filebeat
重点看:
ERRORcannot connectno files foundexited with codefilebeat test config
输出:
Config OK ✅filebeat test output
验证:
filebeat.inputs:
- type: log
paths:
- /var/log/nginx/*.log
检查:
ls -l /var/log/nginx/
getenforce
如果是 Enforcing:
# 临时
setenforce 0
# 永久
vi /etc/selinux/config
SELINUX=disabled
或给文件加权限:
chcon -R -t var_log_t /var/log/nginx
ls -l /var/lib/filebeat/registry/
filebeat export config
或更直观:
curl http://localhost:5066/stats
(需开启 http 监控)
curl -u elastic:password http://localhost:9200/_cat/indices?v
看是否有 filebeat-* 索引
tail -f /var/log/logstash/logstash-plain.log
| 问题 | 原因 | 解决 |
|---|---|---|
| No files found | 路径写错 | 检查 glob |
| permission denied | SELinux / 权限 | chmod / setenforce |
| connection refused | ES 没起 | systemctl start elasticsearch |
| auth error | 账号密码错 | 检查 output |
| 数据不更新 | inode 变化 | 重启 filebeat |
systemctl statusjournalctl -u filebeatfilebeat test configfilebeat test output如果你愿意,可以直接贴一段 filebeat.yml + 报错日志,我可以帮你精准定位。