Ubuntu 上 Filebeat 故障排查手册
一 快速定位流程
sudo systemctl status filebeat、sudo journalctl -u filebeat -f、sudo tail -f /var/log/filebeat/filebeat.log。sudo filebeat test config、sudo filebeat test output、sudo filebeat -e。filebeat.inputs 的 paths 是否覆盖目标日志,确保运行用户对日志文件具备读取权限(必要时检查父目录权限与 ACL)。curl 到 9200/5044),若启用 SSL/认证/API Key,核对证书与凭据是否正确。二 常见故障与修复
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg;echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list;sudo apt update && sudo apt install -y filebeat。filebeat.yml 中放行 rseq(示例见下),或关闭 seccomp(不推荐)。filebeat test config 与 filebeat test output 精确定位;若使用模块(如 system),先执行 filebeat modules enable system 再 filebeat setup 初始化索引模板与仪表板。/var/log/** 与业务日志目录),必要时调整文件/目录属主或以具备权限的用户运行。output.elasticsearch.hosts 或 output.logstash.hosts、索引模板/ILM 策略、以及安全认证;在 ES 侧用 curl -X GET "localhost:9200/_cat/indices?v" 与 curl -X GET "localhost:9200/filebeat-*/_search?pretty&q=*" 验证索引与文档是否存在。三 关键命令清单
sudo systemctl status filebeat、sudo systemctl restart filebeat、sudo journalctl -u filebeat -f、sudo tail -f /var/log/filebeat/filebeat.logsudo filebeat test config、sudo filebeat test output、sudo filebeat -efilebeat version、sudo filebeat modules enable system、filebeat setupcurl -X GET "localhost:9200/_cat/indices?v"、curl -X GET "localhost:9200/filebeat-*/_search?pretty&q=*"四 配置片段示例
seccomp:
default_action: allow
syscalls:
- action: allow
names:
- rseq
filebeat.inputs:
- type: stdin
output.console:
pretty: true
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/syslog
- /var/log/auth.log
output.logstash:
hosts: ["logstash.example.com:5044"]
以上示例分别用于 seccomp 问题定位、前台快速调试与常规日志采集的最小可用配置。