Filebeat 在 Ubuntu 上“不采集”日志,通常不是单一原因,而是配置、权限、状态文件或路径问题导致的。下面按最常见原因 → 排查方法 → 解决方式给你一个系统排查清单。
systemctl status filebeat
或
ps aux | grep filebeat
✅ 正常应看到 filebeat 进程
❌ 如果没运行:
sudo systemctl start filebeat
sudo systemctl enable filebeat
Ubuntu 上通常是:
/etc/filebeat/filebeat.yml
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
⚠️ 常见错误:
enabled: falsepaths 写错(不存在或权限不足)filestream 但旧版本不支持ls -l /var/log/xxx.log
tail -n 20 /var/log/xxx.log
⚠️ Filebeat 不会采集空文件或从未写入过的文件
filebeat
如果日志文件权限是:
-rw------- root root
❌ filebeat 读不了
✅ 解决方式之一:
sudo chmod 644 /var/log/xxx.log
或加入组:
sudo usermod -aG adm filebeat
(很多系统日志属于 adm 组)
Filebeat 用状态文件记录采集位置:
/var/lib/filebeat/registry
如果之前已经采集过,但文件没变化 → 不会再采
sudo systemctl stop filebeat
sudo rm -rf /var/lib/filebeat/registry
sudo systemctl start filebeat
⚠️ 会重新从头采集所有日志
journalctl -u filebeat -f
或
tail -f /var/log/filebeat/filebeat
常见错误示例:
No such file or directorypermission deniedconnection refused(ES / Logstash 没连上)例如输出到 Elasticsearch:
output.elasticsearch:
hosts: ["http://localhost:9200"]
或 Logstash:
output.logstash:
hosts: ["localhost:5044"]
❌ 输出不可达 → 数据“看起来没采集”
| 检查项 | 命令 |
|---|---|
| 是否运行 | systemctl status filebeat |
| 配置是否生效 | filebeat test config |
| 输出是否通 | filebeat test output |
| 是否读到文件 | journalctl -u filebeat |
| 权限 | ls -l 日志文件 |
你可以贴出:
/etc/filebeat/filebeat.ymljournalctl -u filebeat 的报错我可以精准告诉你是哪一行配置或权限问题。