【Docker】 Fluentd와 Elasticsearch와 Re:dash로 로그 관리
도커
docker와 docker-compose 도입
CentOS라면 아래 참조
CentOS6.5에 docker 및 docker-compose 설치
전제
로그 예
hoge_log
{ "type": "chatlog", "name": "hoge1", "text": "hoge1" }
{ "type": "chatlog", "name": "hoge2", "text": "hoge2" }
{ "type": "chatlog", "name": "hoge3", "text": "hoge3" }
{ "type": "chatlog", "name": "hoge4", "text": "hoge4" }
{ "type": "chatlog", "name": "hoge5", "text": "hoge5" }
Fluentd & Elasticsearch
$ mkdir ~/workspace
$ cd ~/workspace
Fluentd
$ mkdir fluentd
$ cd fluentd
$ mkdir plugins
$ vi Dockerfile
$ vi fluent.conf
Dockerfile
FROM fluent/fluentd:latest-onbuild
USER fluent
WORKDIR /home/fluent
ENV PATH /home/fluent/.gem/ruby/2.3.0/bin:$PATH
RUN gem install fluent-plugin-secure-forward
RUN gem install fluent-plugin-elasticsearch
EXPOSE 24284
CMD fluentd -c /fluentd/etc/fluent.conf -p /fluentd/plugins -vv
fluent.conf
<source>
type tail
path /var/log/hoge/[log file] # 収集するログファイル名を指定
tag json.hoge
pos_file /var/log/hoge/[log file].pos # 収集するログファイル名を指定
format json
</source>
<match json.**>
type copy
<store>
type stdout
</store>
<store>
type elasticsearch
host localhost # elasticsearchのホスト
port 9200 # elasticsearchのポート
logstash_format true
</store>
</match>
Elasticsearch
$ mkdir elasticsearch
$ cd elasticsearch
$ vi Dockerfile
Dockerfile
FROM elasticsearch
RUN bin/plugin install mobz/elasticsearch-head
EXPOSE 9200
CMD ["bin/elasticsearch", "-Des.insecure.allow.root=true"]
시작
$ cd ~/workspace
$ vi docker-compose.yml
docker-compose.yml
elasticsearch:
build: elasticsearch
ports:
- 9200:9200
fluentd:
build: fluentd
ports:
- 24284:24284
volumes:
- [log folder]:/var/log/hoge # 収集するログフォルダを指定
$ docker-compose up
Elasticsearch 웹 페이지
http://[IP]:9200/_plugin/head/
Re:dash
자세한 내용은 아래를 참조
Re:dash를 docker로 시작하기
데이터 소스 추가
Settings > DATA SOURCES > NEW DATA SOURCES
Base URL은 이런 느낌
http://[IP]:9200
Reference
이 문제에 관하여(【Docker】 Fluentd와 Elasticsearch와 Re:dash로 로그 관리), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/narumi_/items/59237554ea1c0e713dd9텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)