Filebeat與Elasticsearch協同工作在CentOS上的步驟如下:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.2-linux-x86_64.tar.gz
tar -xzf elasticsearch-7.10.2-linux-x86_64.tar.gz
cd elasticsearch-7.10.2
./bin/elasticsearch
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.10.0-amd64.deb
sudo dpkg -i filebeat-7.10.0-amd64.deb
/etc/filebeat/filebeat.yml
。filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
output.elasticsearch:
hosts: ["localhost:9200"]
index: "filebeat-%{[agent.version]}-%{+yyyy.MM.dd}"
filebeat.inputs
定義了Filebeat要監控的日志文件路徑。output.elasticsearch
定義了Elasticsearch的主機和索引名稱。sudo systemctl start filebeat
sudo systemctl enable filebeat
sudo systemctl status filebeat
http://your_elasticsearch_host:5601
),然后檢查是否有新的索引被創建。curl -X GET "localhost:9200/_cat/indices?v"
你應該能看到一個名為 filebeat-*
的索引,其中包含了Filebeat發送的日志數據。
wget https://artifacts.elastic.co/downloads/kibana/kibana-7.10.2-linux-x86_64.tar.gz
tar -xzf kibana-7.10.2-linux-x86_64.tar.gz
mv kibana-7.10.2 /opt/kibana
/opt/kibana/config/kibana.yml
文件,確保以下配置:server.host: "0.0.0.0"
elasticsearch.hosts: ["http://localhost:9200"]
sudo systemctl start kibana
sudo systemctl enable kibana
現在,你應該能夠在Kibana中看到通過Filebeat發送的日志數據。
通過以上步驟,你已經成功地在CentOS上將Filebeat與Elasticsearch集成,并且可以通過Kibana來可視化和分析日志數據。如果有任何問題,請參考Elastic官方文檔或社區支持。