温馨提示×

centos filebeat如何查看运行状态

小樊
41
2026-08-18 20:42:53
栏目: 智能运维

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 日志(非常重要 ⭐)

1️⃣ systemd 日志

journalctl -u filebeat -f

查看历史日志:

journalctl -u filebeat --since "10 min ago"

2️⃣ Filebeat 自身日志(如已配置)

默认路径(取决于配置):

/var/log/filebeat/filebeat

查看:

tail -f /var/log/filebeat/filebeat

四、使用 Filebeat 命令检查状态

1️⃣ 测试配置文件是否正确

filebeat test config

2️⃣ 测试输出(如 Elasticsearch / Logstash)

filebeat test output

五、查看 Filebeat 是否正在采集日志

1️⃣ 查看 registry 文件(记录采集进度)

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

registry 文件存在且更新,说明 Filebeat 正常运行并采集日志

2️⃣ 查看 Filebeat 当前监听的日志文件

lsof -p $(pgrep filebeat)

六、常见问题排查

❌ Filebeat 启动失败

查看详细错误:

journalctl -u filebeat -xe

❌ 没有采集到日志

检查:

  • filebeat.yml 中的 paths
  • 文件权限
  • SELinux(CentOS 常见坑)

临时关闭 SELinux 测试:

setenforce 0

七、快速检查清单 ✅

systemctl status filebeat
ps -ef | grep filebeat
journalctl -u filebeat -f
filebeat test config
filebeat test output

如果你愿意,可以把 systemctl status filebeat 的输出filebeat.yml 配置贴出来,我可以帮你精确分析为什么没运行或没采集日志。

0