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

猜你喜欢

转载自www.cnblogs.com/histyle/p/10167500.html