温馨提示×

CentOS如何检查Filebeat状态

小樊
41
2026-08-03 21:55:39
栏目: 智能运维

CentOS 上检查 Filebeat 状态,常用方法如下(按使用场景):


一、使用 systemd(最常见,推荐)

如果 Filebeat 是通过 RPM / 官方仓库 安装的,一般都会注册为 systemd 服务。

1️⃣ 查看 Filebeat 运行状态

systemctl status filebeat

常见状态说明:

  • active (running) ✅ 正常运行
  • inactive (dead) ❌ 已停止
  • failed ❌ 启动失败

2️⃣ 启动 / 停止 / 重启

systemctl start filebeat
systemctl stop filebeat
systemctl restart filebeat

3️⃣ 设置开机自启

systemctl enable filebeat

二、查看 Filebeat 进程是否存在

ps -ef | grep filebeat

或:

pgrep -a filebeat

✅ 能看到进程说明 Filebeat 正在运行
❌ 没有输出说明未运行


三、检查 Filebeat 配置是否正确

配置错误是 Filebeat 启动失败的常见原因。

filebeat test config

检查输出是否正常,例如:

Config OK

测试连接(如 Elasticsearch / Logstash)

filebeat test output

四、查看 Filebeat 日志

1️⃣ systemd 日志

journalctl -u filebeat -f

2️⃣ Filebeat 自身日志(取决于配置)

通常在:

/var/log/filebeat/filebeat

查看最新日志:

tail -f /var/log/filebeat/filebeat

五、检查 Filebeat 是否成功发送数据

查看注册文件(记录采集进度)

ls -lh /var/lib/filebeat/registry/

查看 Filebeat 输出目标(如 ES)

curl -X GET "http://localhost:9200/_cat/indices?v"

六、常见问题排查

问题 排查方式
Filebeat 起不来 journalctl -u filebeat
配置错误 filebeat test config
无法连接 ES filebeat test output
没采集到日志 检查 paths 和权限

七、快速状态检查命令总结 ✅

systemctl status filebeat
ps -ef | grep filebeat
filebeat test config
journalctl -u filebeat -n 50

如果你愿意,可以把 systemctl status filebeat 或日志输出贴出来,我可以帮你具体分析为什么 Filebeat 没正常工作。

0