Skip to content

Instantly share code, notes, and snippets.

@cgetc
Last active June 13, 2016 02:15
Show Gist options
  • Save cgetc/5193738a4f74c89ebf6a to your computer and use it in GitHub Desktop.
Save cgetc/5193738a4f74c89ebf6a to your computer and use it in GitHub Desktop.
docker-composeでfluentd + elasticsearch + kibana4 環境をつくる ref: http://qiita.com/cgetc/items/345e3c686910b30ba49f
fluentd:
build: ./fluentd
links:
- "elasticsearch"
# Fluentd logging driver対応の場合
ports:
- "22422:22422"
# Fluentd logging driver非対応の場合
volumes:
- /var/lib/docker/containers:/var/lib/docker/containers
- /var/run:/var/run
- /var/log/docker:/var/log/docker
elasticsearch:
build: elasticsearch
expose:
- 9200
kibana:
image: kibana
links:
- "elasticsearch"
ports:
- "5601:5601"
FROM kiyoto/fluentd:0.10.56-2.1.1
MAINTAINER [email protected]
RUN mkdir /etc/fluent
ADD fluent.conf /etc/fluent/
RUN ["apt-get", "update"]
RUN ["apt-get", "install", "--yes", "make", "libcurl4-gnutls-dev"]
RUN ["/usr/local/bin/gem", "install", "fluent-plugin-elasticsearch", "--no-rdoc", "--no-ri"]
RUN ["/usr/local/bin/gem", "install", "fluent-plugin-record-reformer", "--no-rdoc", "--no-ri"]
RUN ["/usr/local/bin/gem", "install", "fluent-plugin-docker-tag-resolver", "--no-rdoc", "--no-ri"]
ENTRYPOINT ["/usr/local/bin/fluentd", "-c", "/etc/fluent/fluent.conf"]
mkdir -p fluentd/plugins
FROM fluent/fluentd
RUN ["gem", "install", "fluent-plugin-elasticsearch", "--no-rdoc", "--no-ri"]
docker-compose up -d
FROM kiyoto/fluentd:0.10.56-2.1.1
MAINTAINER [email protected]
RUN mkdir /etc/fluent
ADD fluent.conf /etc/fluent/
RUN ["apt-get", "update"]
RUN ["apt-get", "install", "--yes", "make", "libcurl4-gnutls-dev"]
RUN ["/usr/local/bin/gem", "install", "fluent-plugin-elasticsearch", "--no-rdoc", "--no-ri"]
RUN ["/usr/local/bin/gem", "install", "fluent-plugin-record-reformer", "--no-rdoc", "--no-ri"]
RUN ["/usr/local/bin/gem", "install", "fluent-plugin-docker-tag-resolver", "--no-rdoc", "--no-ri"]
ENTRYPOINT ["/usr/local/bin/fluentd", "-c", "/etc/fluent/fluent.conf"]
FROM elasticsearch
RUN echo "network.bind_host: 0.0.0.0" >> /usr/share/elasticsearch/config/elasticsearch.yml
docker-compose up -d
<source>
type tail
path /var/lib/docker/containers/*/*-json.log
pos_file /var/log/fluentd-docker.pos
time_format %Y-%m-%dT%H:%M:%S
tag docker.log.*
format json
</source>
<match docker.log.**>
type docker_tag_resolver
</match>
<match docker.container.**>
type record_reformer
container_id ${tag_parts[4]}
container_name ${tag_parts[3]}
tag docker.all
</match>
<match docker.all>
type elasticsearch
log_level debug
host elasticsearch
port 9200
include_tag_key true
logstash_format true
flush_interval 5s
</match>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment