新聞中心
Filebeat是用于轉(zhuǎn)發(fā)和集中日志數(shù)據(jù)的輕量級(jí)傳送程序。作為服務(wù)器上的代理安裝,F(xiàn)ilebeat監(jiān)視您指定的日志文件或位置,收集日志事件,并將它們轉(zhuǎn)發(fā)到Elasticsearch或Logstash進(jìn)行索引。

網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)公司!專注于網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、成都小程序開發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了延壽免費(fèi)建站歡迎大家使用!
一、架構(gòu)圖
此次試驗(yàn)基于前幾篇文章,需要先基于前幾篇文章搭建基礎(chǔ)環(huán)境。
二、安裝Filebeat
下載并安裝Filebeat
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.0.1-x86_64.rpm
yum install ./filebeat-6.0.1-x86_64.rpm
修改Filebeat配置文件
vim /etc/filebeat/filebeat.yml # 主配置文件
\- type: log # 文檔類型
paths:
\- /var/log/httpd/access.log* # 從哪里讀入數(shù)據(jù)
# 輸出在elasticsearch與logstash二選一即可
output.elasticsearch: #將數(shù)據(jù)輸出到Elasticsearch。與下面的logstash二者選一
hosts: ["localhost:9200"]
output.logstash: # 將數(shù)據(jù)傳送到logstash,要配置logstash使用beats接收
hosts: ["172.18.68.14:5044"]
啟動(dòng)Filebeat
systemctl start filebeat
三、配置Filebeat
配置Logstash接收來自Filebeat采集的數(shù)據(jù)
vim /etc/logstash/conf.d/test.conf
input {
beats {
port => 5044 # 監(jiān)聽5044用于接收Filebeat傳來數(shù)據(jù)
}
}
filter {
grok {
match => {
"message" => "%{COMBINEDAPACHELOG}" # 匹配HTTP的日志
}
remove_field => "message" # 不顯示原信息,僅顯示匹配后
}
}
output {
elasticsearch {
hosts => ["http://172.18.68.11:9200","http://172.18.68.12:9200","http://172.18.68.13:9200"] # 集群IP
index => "logstash-%{+YYYY.MM.dd}"
action => "index"
document_type => "apache_logs"
}
}
啟動(dòng)Logstash
/usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/test.conf
四、模擬日志訪問
通過curl命令來模擬客戶訪問,生成訪問日志
curl 127.0.0.1
curl 172.18.68.51
curl 172.18.68.52
curl 172.18.68.53
五、驗(yàn)證信息
清除之前實(shí)驗(yàn)的舊數(shù)據(jù)(刪除時(shí)要在對話框中輸入刪除),然后可以看到filebeat采集數(shù)據(jù)經(jīng)過Logtash過濾再送給Elasticsearch的數(shù)據(jù)。
擴(kuò)展
隨著ELK日志系統(tǒng)逐漸升級(jí),現(xiàn)在已經(jīng)能基于Filebeat采集各節(jié)點(diǎn)日志,Logstash過濾、修剪數(shù)據(jù),最后到ELasticsearch中進(jìn)行索引構(gòu)建、分詞、構(gòu)建搜索引擎?,F(xiàn)在可以基于Elasticsearch的Head查看在瀏覽器中查看,但是Head僅僅能簡單查看并不能有效進(jìn)行數(shù)據(jù)分析、有好展示。要想進(jìn)行數(shù)據(jù)分析、有好展示那就需要用到Kibana,Kibana依然放在下一篇文章中講解,這里先放上架構(gòu)圖。
文章名稱:快速上手Filebeat
網(wǎng)站網(wǎng)址:http://fisionsoft.com.cn/article/dpjghed.html


咨詢
建站咨詢
