Yamaha 라우터 (RTX810) 로그를 syslog로 건너 뛰고 docker + EFK로보기
개요
RTX810 본체라고 로그를 3000행 밖에 모이지 않기 때문에, syslog로 전송한다.
fluentd와 Elasticsearch, Kibana는 docker로 하나의 호스트에 구축.
파일 구성
파일과 디렉토리 구성은 다음과 같습니다.
syslog 로그는 Elasticsearch로 건너 뛰고 log
디렉토리에도 저장합니다.
├── docker-compose.yaml
├── fluentd
│ ├── Dockerfile
│ └── fluent.conf
└── log
docker-compose는 이런 느낌.
docker-compose.yamlversion: '2'
services:
fluentd:
build: ./fluentd
environment:
FLUENTD_CONF: fluent.conf
restart: always
volumes:
- ./fluentd/fluent.conf:/fluentd/etc/fluent.conf
- ./log:/home/fluent/syslog
ports:
- "514:5140/udp"
depends_on:
- elasticsearch
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.3
volumes:
- esdata:/usr/share/elasticsearch/data
- esconfig:/usr/share/elasticsearch/config
expose:
- "9200"
restart: always
environment:
- bootstrap.memory_lock=true
- xpack.security.enabled=false
- xpack.monitoring.enabled=false
- xpack.watcher.enabled=false
- xpack.graph.enabled=false
- xpack.ml.enabled=false
- http.max_content_length=1g
- thread_pool.index.queue_size=-1
- thread_pool.bulk.queue_size=-1
- "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"
ulimits:
memlock:
soft: -1
hard: -1
mem_limit: 2g
kibana:
image: docker.elastic.co/kibana/kibana:5.6.3
ports:
- "5601:5601"
restart: always
environment:
- "ELASTICSEARCH_URL=http://elasticsearch:9200"
- xpack.graph.enabled=false
- xpack.security.enabled=false
- xpack.ml.enabled=false
depends_on:
- elasticsearch
volumes:
esdata:
driver: local
esconfig:
driver: local
fluentd/DockerfileFROM fluent/fluentd
RUN gem install fluent-plugin-elasticsearch
fluentd 컨테이너에서 514/udp 포트를 열려고 해도 오류가 발생했기 때문에,docker-compose
에서 514⇒5140에 매핑하는 설정으로 하고, 컨테이너에서는 in_syslog 플러그인으로 5140 포트로 받도록(듯이) 했다.
RTX810에서 보낸 syslog는 message_format
에 rfc3164
또는 rfc5424
잘 어울리지 않았기 때문에 전체를 차지했습니다.
받은 로그는 copy 플러그인으로 Elasticsearch와 file로 출력.file
의 출력처는 허가로부터 봐 /home/fluent/
/var/log/
에서 format single_value
만 파일에 내보내고,message
로 내보낸 파일을 압축.
fluentd/fluent.conf<source>
@type syslog
port 5140
bind 0.0.0.0
format /^? *(?<message>.*)$/
time_format %Y/%m/%d %h:%M:%s
tag syslog
</source>
<match syslog.**>
@type copy
<store>
@type elasticsearch
include_tag_key true
tag_key _tag
host elasticsearch
port 9200
logstash_format true
logstash_prefix logstash
buffer_type file
buffer_path /tmp/fluentd*.buffer
# buffer_chunk_limit 1g
# buffer_queue_limit 256
# flush_interval 60s
# retry_wait 5s
</store>
<store>
@type file
path /home/fluent/syslog/log
compress gzip
format single_value
</store>
</match>
이상의 파일을 준비하면 컨테이너 기동.
docker-compose build
docker-compose up -d
RTX810 설정
├── docker-compose.yaml
├── fluentd
│ ├── Dockerfile
│ └── fluent.conf
└── log
version: '2'
services:
fluentd:
build: ./fluentd
environment:
FLUENTD_CONF: fluent.conf
restart: always
volumes:
- ./fluentd/fluent.conf:/fluentd/etc/fluent.conf
- ./log:/home/fluent/syslog
ports:
- "514:5140/udp"
depends_on:
- elasticsearch
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.3
volumes:
- esdata:/usr/share/elasticsearch/data
- esconfig:/usr/share/elasticsearch/config
expose:
- "9200"
restart: always
environment:
- bootstrap.memory_lock=true
- xpack.security.enabled=false
- xpack.monitoring.enabled=false
- xpack.watcher.enabled=false
- xpack.graph.enabled=false
- xpack.ml.enabled=false
- http.max_content_length=1g
- thread_pool.index.queue_size=-1
- thread_pool.bulk.queue_size=-1
- "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"
ulimits:
memlock:
soft: -1
hard: -1
mem_limit: 2g
kibana:
image: docker.elastic.co/kibana/kibana:5.6.3
ports:
- "5601:5601"
restart: always
environment:
- "ELASTICSEARCH_URL=http://elasticsearch:9200"
- xpack.graph.enabled=false
- xpack.security.enabled=false
- xpack.ml.enabled=false
depends_on:
- elasticsearch
volumes:
esdata:
driver: local
esconfig:
driver: local
FROM fluent/fluentd
RUN gem install fluent-plugin-elasticsearch
<source>
@type syslog
port 5140
bind 0.0.0.0
format /^? *(?<message>.*)$/
time_format %Y/%m/%d %h:%M:%s
tag syslog
</source>
<match syslog.**>
@type copy
<store>
@type elasticsearch
include_tag_key true
tag_key _tag
host elasticsearch
port 9200
logstash_format true
logstash_prefix logstash
buffer_type file
buffer_path /tmp/fluentd*.buffer
# buffer_chunk_limit 1g
# buffer_queue_limit 256
# flush_interval 60s
# retry_wait 5s
</store>
<store>
@type file
path /home/fluent/syslog/log
compress gzip
format single_value
</store>
</match>
docker-compose build
docker-compose up -d
compress gzip
에서 docker 호스트 IP (이 예에서는 syslog host
)를 지정 192.168.100.221
는 좋아합니다 (아래는 syslog facility
) local7
, notice
, info
, debug
syslog host 192.168.100.221
syslog facility local7
syslog notice on
syslog info on
syslog debug on
키바나
브라우저에서 http://192.168.100.221:5601/
로 이동합니다.
먼저 인덱스 패턴을 작성하면 눈에 띄는 로그가 표시됩니다.
Reference
이 문제에 관하여(Yamaha 라우터 (RTX810) 로그를 syslog로 건너 뛰고 docker + EFK로보기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/330k/items/7c266b44d4a23f017634
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
Reference
이 문제에 관하여(Yamaha 라우터 (RTX810) 로그를 syslog로 건너 뛰고 docker + EFK로보기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/330k/items/7c266b44d4a23f017634텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)