ELK、Filebeat環境搭建

簡介

ELK爲Elasticsearch、Logstash、Kibana簡稱,Filebeat爲日誌傳輸工具

  • Elasticsearch The Heart of the Elastic Stack,Elasticsearch是一個基於分佈式RESTful風格的搜索和分析引擎,能夠解決越來越多的用例,作爲Elastic Stack的核心,它集中存儲數據,以便預期發現意外情況
  • Logstash Logstash是一個開源的服務器端數據處理管道,它可以同時從多個源中提取數據,對其進行轉換,然後將其發送到您最喜歡的"存儲"
  • Kibana Your Window into the Elastic Stack,Kibana用來可視化Elasticsearch數據
  • Filebeat 輕量級的日誌、文件傳輸工具,filebeat會使用一個反壓力敏感(backpressure-sensitive)的協議來解釋高負荷的數據量,當數據處理繁忙時,Filebeat放慢它的讀取速度.一旦壓力解除,將恢復到原來的速度,繼續傳輸數據 簡單的來說,Filebeat用來檢測數據,把數據發送給Logstash,Logstash是具備實時傳輸數據的管道,將數據從管道的輸入端傳輸到輸出端,而且可以根據需要過濾、處理數據,Elasticsearch 是一個分佈式搜索引擎,負責數據的存儲、檢索、分析,Kibana提供了可視化的界面,用於數據的可視化操作.

安裝

從https://www.elastic.co/products官網上下載最新的安裝包

  • 配置Elasticsearch 修改文件/elasticsearch-6.3.2/config/elasticsearch.yml:
cluster.name: lios-boot-rest
node.name: lios-boot
path.data: /Users/wenchao.wang/dev/elk/logs
path.logs: /Users/wenchao.wang/dev/elk/logs
network.host: 127.0.0.1
http.port: 9200

啓動服務: ./elasticsearch-6.3.2/bin/elasticsearch

  • 配置Logstash 在/logstash-6.3.2/config目錄下新建配置文件filebeat-to-es.conf:
input {
beats{
    type => "lios-boot-rest"
    host => "127.0.0.1"
    port => 5044
  }
}
output {
 elasticsearch{
 hosts => ["127.0.0.1:9200"]
 index => "lios-boot-rest-%{+YYYY.MM.dd}"
 }
}

啓動服務: ./logstash-6.3.2/bin/logstash-f./filebeat-to-es.conf

  • 配置kibana
server.port: 5601
server.host: "127.0.0.1"
elasticsearch.url: "http://127.0.0.1:9200"
kibana.index: ".kibana"

啓動服務: ./kibana-6.3.2-darwin-x86_64/bin kibana

  • 配置filebeat
filebeat.inputs:
- type: log
  # Change to true to enable this input configuration.
  enabled: true
  # Paths that should be crawled and fetched. Glob based paths.
  paths:
  - /data/lios/logs/apps/lios-boot-rest/*.log
  tags: ["lios-boor-rest-log"]
  document_type: lios-boot-rest
  spool_size: 1024
  idle_timeout: "3s"
filebeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false
  # Period on which files under path should be checked for changes
  #reload.period: 10s
setup.template.settings:
  index.number_of_shards: 3
#----------------------------- Logstash output --------------------------------
output.logstash:
  # The Logstash hosts
  hosts: ["127.0.0.1:5044"]

啓動filebeat服務

mac上啓動方式
sudo chown root filebeat.yml
sudo ./filebeat -e -c filebeat.yml -d "publish"

發現filebeat已經向logstash發送數據了:

可視化

網址中輸入 http://localhost:5601/

創建索引:

創建索引成功後,發現已經可以看到數據了:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章