在 CentOS 上把 Filebeat 接入 Elasticsearch(ES),通常分为 安装 Filebeat → 配置输出到 ES → 启动并验证 几个步骤。下面给你一套最常用、可直接落地的做法(ES 8.x 也适用,含安全认证说明)。
/var/log/*.log# 导入 GPG
sudo rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
# 添加 yum 源(以 8.x 为例)
sudo cat > /etc/yum.repos.d/filebeat.repo <<EOF
[elastic-8.x]
name=Elastic repository for 8.x packages
baseurl=https://artifacts.elastic.co/packages/8.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
EOF
# 安装
sudo yum install filebeat -y
vi /etc/filebeat/filebeat.yml
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
output.elasticsearch:
hosts: ["http://192.168.1.100:9200"]
output.elasticsearch:
hosts: ["https://192.168.1.100:9200"]
username: "elastic"
password: "your_password"
ssl.verification_mode: none
生产环境建议配置
ssl.certificate_authorities
filebeat setup --index-management -E output.elasticsearch.hosts=["192.168.1.100:9200"]
systemctl enable filebeat
systemctl start filebeat
systemctl status filebeat
journalctl -u filebeat -f
curl http://192.168.1.100:9200/_cat/indices?v
你应该能看到类似:
filebeat-8.x.x-2026.03.19
curl -X GET "http://192.168.1.100:9200/filebeat-*/_search?size=1"
9200 是否开放localhostxpack.securityenabled: true 是否配置setup.kibana:
host: "http://192.168.1.101:5601"
然后:
filebeat setup
如果你告诉我:
我可以直接给你一份完整可用的 filebeat.yml。