docker-efk収集dockerログの構築
3376 ワード
version: '2'
services:
fluentd:
build: ./fluentd
volumes:
- ./fluentd/conf:/fluentd/etc
links:
- "elasticsearch"
ports:
- "24224:24224"
- "24224:24224/udp"
elasticsearch:
image: elasticsearch
volumes:
- ./es/data:/usr/share/elasticsearch/data
expose:
- 9200
ports:
- "9200:9200"
kibana:
image: kibana
volumes:
- ./kibana/plugins/:/usr/share/kibana/plugins/
links:
- "elasticsearch"
ports:
- "5601:5601"
FROM fluent/fluentd:v0.12-debian
RUN ["gem", "install", "fluent-plugin-elasticsearch", "--no-rdoc", "--no-ri", "--version", "1.9.2"]
fluentdディレクトリの下にconf/fluentを新規作成します.conf
<source>
@type forward
port 24224
bind 0.0.0.0
source>
<match *.**>
@type copy
<store>
@type elasticsearch
host elasticsearch
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>
"log-driver":"fluentd",
"log-opts":{
"fluentd-address":"192.168.0.133:24224"
},
なお、このときfluentdサービスが停止して起動できない場合は、サービス起動時に--log-opt=fluentd-async-connect
転載先:https://www.cnblogs.com/1ssqq1lxr/p/9571374.html