温馨提示×

ubuntu filebeat如何排查错误

小樊
42
2026-10-25 16:30:43
栏目: 智能运维

在 Ubuntu 上排查 Filebeat 错误,通常可以按下面几个步骤系统性地进行。


一、查看 Filebeat 状态

systemctl status filebeat

常见状态:

  • active (running):正常运行
  • failed:启动失败(看日志)
  • inactive:未启动

启动 / 重启:

sudo systemctl start filebeat
sudo systemctl restart filebeat

二、查看 Filebeat 日志(最重要)

1. journald 日志(推荐)

journalctl -u filebeat -f

或查看历史:

journalctl -u filebeat --since "1 hour ago"

2. Filebeat 自身日志文件

默认位置:

/var/log/filebeat/filebeat

查看错误:

tail -n 100 /var/log/filebeat/filebeat

三、使用 Filebeat 自带测试命令

1. 测试配置文件

filebeat test config

✅ 输出 Config OK 表示配置语法没问题

2. 测试输出(Elasticsearch / Logstash)

filebeat test output

常见问题:

  • 地址错误
  • 端口不通
  • 认证失败

四、开启 Debug 日志(排错利器)

编辑配置:

sudo vi /etc/filebeat/filebeat.yml

在末尾添加:

logging.level: debug
logging.selectors: ["*"]

重启:

sudo systemctl restart filebeat

查看详细日志:

journalctl -u filebeat -f

五、检查输入(日志路径)问题

常见错误

  • 路径不存在
  • 权限不足
  • 文件未被读取

示例配置:

filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /var/log/nginx/*.log

检查:

ls -l /var/log/nginx/

权限不足时:

sudo usermod -aG adm filebeat

六、检查输出目标(ES / Logstash)

Elasticsearch

curl -X GET "http://localhost:9200"

Logstash

telnet logstash_ip 5044

Filebeat 常见输出错误:

  • connection refused
  • 401 Unauthorized
  • x509 certificate error

七、查看 Filebeat 注册文件(已读位置)

/var/lib/filebeat/registry/

如果日志“不更新”:

  • 删除 registry(⚠谨慎)
sudo systemctl stop filebeat
sudo rm -rf /var/lib/filebeat/registry
sudo systemctl start filebeat

八、常见错误速查表

现象 原因
Exiting: error loading config yml 格式错误
No files found 路径/权限问题
connection reset by peer ES/Logstash 端口不通
permission denied filebeat 用户无读权限
数据不更新 registry 已记录偏移

九、官方排查文档

https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-troubleshooting.html

如果你愿意,可以把 具体错误信息(日志片段或 filebeat test output 输出)贴出来,我可以直接帮你定位问题。

0 踩