Filebeat与Elasticsearch的协作机制
典型部署与数据流向
快速上手配置示例
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
output.elasticsearch:
hosts: ["your_es_host:9200"]
index: "filebeat-%{+yyyy.MM.dd}"
sudo systemctl start filebeat
sudo systemctl enable filebeat
sudo journalctl -u filebeat -f
curl -X GET "localhost:9200/_cat/indices?v" | grep filebeat
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
filebeat.config.modules:
path: ${path.config}/modules.d/*.yml
reload.enabled: true
output.elasticsearch:
hosts: ["your_es_host:9200"]
username: "filebeat_internal"
password: "YOUR_PASSWORD"
index: "filebeat-%{[agent.version]}-%{+yyyy.MM.dd}"
setup.kibana:
host: "your_kibana_host:5601"
username: "kibana_user"
password: "YOUR_PASSWORD"
filebeat setup -e加载索引模板与仪表板,再启动服务。生产环境最佳实践
output.elasticsearch与setup.kibana中配置用户名/密码或使用API Key;启用TLS加密传输。filebeat-%{+yyyy.MM.dd}),结合**ILM(索引生命周期管理)**实现热/温/冷/删除的自动化管理,控制存储成本并提升查询性能。