温馨提示×

如何查看CentOS Filebeat状态

小樊
44
2026-07-20 08:25:01
栏目: 智能运维

在 CentOS 上查看 Filebeat 状态,通常取决于你是通过 systemd 还是 直接运行。下面是最常见的几种方式:


一、使用 systemd(最常见)

1️⃣ 查看 Filebeat 运行状态

systemctl status filebeat

输出示例:

● filebeat.service - Filebeat sends log files to Logstash or directly to Elasticsearch.
   Loaded: loaded (/usr/lib/systemd/system/filebeat.service; enabled; vendor preset: disabled)
   Active: active (running) since ...

2️⃣ 查看是否开机自启

systemctl is-enabled filebeat
  • enabled = 开机自启
  • disabled = 未自启

3️⃣ 启动 / 停止 / 重启

systemctl start filebeat
systemctl stop filebeat
systemctl restart filebeat

二、查看 Filebeat 进程

查看进程是否存在

ps -ef | grep filebeat

pgrep -a filebeat

三、查看 Filebeat 日志

1️⃣ systemd 日志(推荐)

journalctl -u filebeat -f

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

常见路径:

/var/log/filebeat/filebeat

查看:

tail -f /var/log/filebeat/filebeat

四、测试 Filebeat 配置是否正确

filebeat test config

如果配置正常,会显示:

Config OK

五、测试输出(Elasticsearch / Logstash)

filebeat test output

六、常见状态说明

状态 含义
active (running) 正常运行
inactive (dead) 未运行
failed 启动失败

七、如果提示 Unit filebeat.service could not be found

说明可能是 手动运行未注册 systemd 服务,可以直接运行:

filebeat -e -c /etc/filebeat/filebeat.yml

如果你愿意,可以告诉我:

  • ✅ CentOS 7 / 8 / Stream?
  • ✅ Filebeat 是 rpm 安装的,还是 tar 包?
  • ✅ 想排查日志是否发到 ES / Logstash?

我可以帮你进一步定位问题。

0