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.confdocker
<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-connectjson