在 CentOS 上让 Filebeat 连接 Elasticsearch(ES),核心就是:
✅ 安装 Filebeat
✅ 修改 filebeat.yml
✅ 启动并验证
下面给你一个完整、可直接用的流程(适用于 Filebeat → Elasticsearch 直连,不走 Logstash)。
# 以 8.11.0 为例,换成你的版本
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.11.0-x86_64.rpm
sudo rpm -ivh filebeat-8.11.0-x86_64.rpm
安装完成后:
filebeat version
sudo vi /etc/filebeat/filebeat.yml
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
output.elasticsearch:
hosts: ["http://192.168.1.10:9200"]
username: "elastic"
password: "your_password"
⚠️ 如果 ES 没开安全认证,可以去掉
username / password
setup.template.name: "filebeat"
setup.template.pattern: "filebeat-*"
setup.kibana:
host: "http://192.168.1.10:5601"
output.elasticsearch:
hosts: ["https://192.168.1.10:9200"]
username: "elastic"
password: "your_password"
ssl.verification_mode: none # 如果是自签证书
sudo filebeat setup
如果只想加载模板:
sudo filebeat setup --index-management
sudo systemctl enable filebeat
sudo systemctl start filebeat
查看状态:
systemctl status filebeat
curl -u elastic:your_password http://192.168.1.10:9200/_cat/indices/filebeat*?v
curl -u elastic:your_password http://192.168.1.10:9200/filebeat-*/_search?pretty
connection attempt failed
✅ 检查:
✅ 检查:
filebeat.inputs.enabled: true| 方案 | 推荐场景 |
|---|---|
| Filebeat → ES | 简单、轻量 |
| Filebeat → Logstash → ES | 需要过滤、解析 |
如果你愿意,可以告诉我:
我可以帮你直接生成一份可用的 filebeat.yml ✅