温馨提示×

ubuntu filebeat怎么开启调试

小樊
44
2026-10-11 00:54:33
栏目: 智能运维

在 Ubuntu 上开启 Filebeat 调试(debug) 通常有几种方式,按使用场景从简单到完整说明:


一、命令行临时开启调试(最常用)

运行 Filebeat 时加 -d 参数:

sudo filebeat -e -d "*"

说明:

  • -e:日志直接输出到终端(stderr)
  • -d "*":开启所有调试模块
  • 也可指定模块,如:
    sudo filebeat -e -d "publish,registrar,input"
    

适合 临时排查问题。


二、修改 filebeat.yml 开启调试日志

编辑配置文件:

sudo vim /etc/filebeat/filebeat.yml

在末尾或适当位置添加:

logging.level: debug
logging.to_files: true
logging.files:
  path: /var/log/filebeat
  name: filebeat
  keepfiles: 7
  permissions: 0644

然后重启:

sudo systemctl restart filebeat

查看日志:

tail -f /var/log/filebeat/filebeat

三、只输出到控制台(不写文件)

logging.level: debug
logging.to_files: false
logging.to_stderr: true

适合容器或临时调试。


四、开启 HTTP 调试接口(高级)

http.enabled: true
http.host: localhost
http.port: 5066

然后访问:

curl http://localhost:5066/state
curl http://localhost:5066/inputs

五、常见问题排查建议

  1. 确认 filebeat 是否在运行

    systemctl status filebeat
    
  2. 测试配置是否正确

    sudo filebeat test config
    sudo filebeat test output
    
  3. 调试输入不到 ES / Logstash

    sudo filebeat -e -d "publish,output"
    

如果你能告诉我:

  • Filebeat 版本
  • 输出目标(ES / Logstash / Kafka)
  • 具体现象(采集不到?报错?)

我可以给你更精确的调试方案。

0 踩