docker搭建日誌收集系統EFK
阿新 • • 發佈:2018-12-24
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