docker搭建日志收集系統EFK


EFK

  • Elasticsearch是一個數據搜索引擎和分布式NoSQL數據庫的組合,提過日志的存儲和搜索功能。
  • Fluentd是一個消息采集,轉化,轉發工具,目的是提供中心化的日志服務。
  • Kibana是一個帶有強大數據整理,分析的web前端,將數據以可視化的方式呈現給用戶。
注意:
  • docker hub 上 elastic 不再更新,直接去elastic官網
  • fluend image from dokcer hub

下載鏡像

docker pull docker.elastic.co/elasticsearch/elasticsearch:6.5.4

docker pull docker.elastic.co/kibana/kibana:6.5.4

docker pull fluent/fluentd:v1.3.2-debian-1.0
fluentd需要安裝elasticsearch插件
#編輯Dockerfile
FROM fluent/fluentd:v1.3.2-debian-1.0
RUN ["gem", "install", "fluent-plugin-elasticsearch"]

#docker build
docker build . -t fluentd:1.3.2

運行容器

docker create --network host --name elasticsearch -e discovery.type=single-node --restart always docker.elastic.co/elasticsearch/elasticsearch:6.5.4

#/home/iot/work/elk/conf:/fluentd/etc
docker create --network host --name fluentd -v /home/iot/work/elk/conf:/fluentd/etc --restart always fluentd:1.3.2

docker create --network host --name kibana -e ELASTICSEARCH_URL=http://127.0.0.1:9200 --restart always docker.elastic.co/kibana/kibana:6.5.4

#啟動容器
docker start elasticsearch  fluentd  kibana 
#fluent.conf

<source>
@type forward
port 24224
bind 0.0.0.0
</source>
<match *.**>
@type copy
<store>
@type elasticsearch
host 127.0.0.1
port 9200
logstash_format true
logstash_prefix fluentd
logstash_dateformat %Y%m%d
include_tag_key true
type_name access_log
tag_key @log_name
flush_interval 1s
</store>
<store>
@type stdout
</store>
</match>

到此EFK就安裝完成了,可以直接訪問 訪問kibana


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM