温馨提示×

centos filebeat如何看日志

小樊
43
2026-10-23 12:25:16
栏目: 智能运维

在 CentOS 上查看 Filebeat 相关日志,通常从以下几个地方入手,按使用场景分类说明:


一、查看 Filebeat 自身运行日志(最常用)

Filebeat 默认会把运行日志写到系统 journal 或文件中。

1️⃣ 使用 systemd(推荐,CentOS 7+)

journalctl -u filebeat -f
  • -f:实时跟踪日志
  • 查看历史:
journalctl -u filebeat --since "1 hour ago"

2️⃣ 查看 Filebeat 日志文件(如果配置了)

编辑配置文件:

vi /etc/filebeat/filebeat.yml

常见配置:

logging:
  level: info
  to_files: true
  files:
    path: /var/log/filebeat
    name: filebeat
    keepfiles: 7

查看日志:

ls /var/log/filebeat/
tail -f /var/log/filebeat/filebeat

二、查看 Filebeat 采集的业务日志

Filebeat 本身不存储业务日志,它只是采集并发送。

1️⃣ 确认采集的日志路径

cat /etc/filebeat/filebeat.yml

示例:

filebeat.inputs:
- type: log
  paths:
    - /var/log/nginx/*.log

查看被采集的日志:

tail -f /var/log/nginx/access.log

三、确认 Filebeat 是否正常工作

1️⃣ 查看 Filebeat 状态

systemctl status filebeat

2️⃣ 测试配置文件

filebeat test config

3️⃣ 查看输出目标(Elasticsearch / Logstash)

filebeat test output

四、常见排错命令

看 Filebeat 进程

ps -ef | grep filebeat

看端口(如输出到 Logstash)

netstat -tunlp | grep 5044

看是否有错误

journalctl -u filebeat | grep -i error

五、如果你用的是 ELK

如果你把日志发到 Elasticsearch + Kibana:

  • 登录 Kibana
  • 查看 filebeat-* 索引
  • 使用 Discover 查看日志

如果你能告诉我:

  • CentOS 版本
  • Filebeat 输出到哪里(ES / Logstash / Kafka)
  • 想看「Filebeat 日志」还是「业务日志」

我可以给你更精确的命令。

0 踩