在 Debian 上把 Filebeat 的输出配置到 Elasticsearch(ES),核心就是修改 filebeat.yml 里的 output.elasticsearch。下面给你一个从安装到验证的完整流程。
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb https://artifacts.elastic.co/packages/8.x/apt stable main" \
| sudo tee /etc/apt/sources.list.d/elastic-8.x.list
sudo apt update
sudo apt install filebeat
如果要用 7.x,把
8.x改成7.x
编辑配置文件:
sudo vim /etc/filebeat/filebeat.yml
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
output.elasticsearch:
hosts: ["http://127.0.0.1:9200"]
# 如果 ES 开启了认证
# username: "elastic"
# password: "你的密码"
# 可选:关闭 ILM
setup.ilm.enabled: false
output.elasticsearch:
hosts: ["https://es-node:9200"]
username: "elastic"
password: "password"
ssl.verification_mode: none # 如果是自签证书
output.elasticsearch:
hosts: ["https://es-node:9200"]
api_key: "id:api_key"
sudo filebeat setup --index-management -E output.logstash.enabled=false -E output.elasticsearch.hosts=["http://127.0.0.1:9200"]
或全量初始化(仪表盘 + 模板):
sudo filebeat setup
sudo systemctl enable filebeat
sudo systemctl start filebeat
查看状态:
sudo systemctl status filebeat
journalctl -u filebeat -f
curl -X GET "http://127.0.0.1:9200/_cat/indices/filebeat*?v"
curl -X GET "http://127.0.0.1:9200/filebeat-*/_search?pretty"
hosts 是否写对9200xpack.security.enabled: truepaths 文件存在且非空filebeat 是否有权限读日志setup.kibana:
host: "http://127.0.0.1:5601"
setup.template.name: "filebeat"
setup.template.pattern: "filebeat-*"
如果你愿意,可以告诉我:
我可以给你一份完全贴合你环境的 filebeat.yml。