Filebeat與Elasticsearch協同工作主要通過以下步驟實現:
filebeat.yml
中指定要采集的日志文件路徑,如paths: ["/var/log/nginx/*.log"]
。output.elasticsearch: hosts: ["localhost:9200"]
,可添加認證信息(用戶名/密碼)。setup.template
配置索引名稱、分片數等,優化數據存儲和查詢效率。sudo systemctl start filebeat
啟動Filebeat,并設置開機自啟。bulk_max_size
(批量發送大?。?、flush_interval
(發送間隔)等,提升傳輸效率。核心邏輯:Filebeat作為輕量級采集端,負責高效采集日志并實時傳輸至Elasticsearch,后者負責存儲、索引和提供搜索分析能力,兩者結合實現日志的全生命周期管理。