반응형
    
    
    
  Fluentd를 Docker 컨테이너로 실행하는 방법
Fluentd 컨테이너 실행
mkdir -p /fluentd/logchown -R 999.999 /fluentddocker run -d --name fluentd \
-p 24224:24224 \
-v /fluentd/log:/fluentd/log \
fluent/fluentdFluentd를 Docker Compose를 사용하여 컨테이너 실행
mkdir -p docker/configmkdir -p fluentd/logchown -R 999.999 fluentddocker-compose.yml 파일 생성
vim docker-compose.ymlversion: '3.8'
services:
  fluentd:
    build: ./docker
    image: anti1346/fluentd:v1.12-debian
    restart: unless-stopped
    container_name: fluentd
    hostname: fluentd
    volumes:
      - /usr/share/zoneinfo/Asia/Seoul:/etc/localtime:ro
      - ./docker/config/fluent.conf:/fluentd/etc/fluent.conf
      #- ./docker/config/fluent-es.conf:/fluentd/etc/fluent.conf
      - ./fluentd/plugins:/fluentd/plugins
      - ./fluentd/log:/fluentd/log
    #network_mode: host
    ports:
      - "8888:8888"
      - "24224:24224"
      - "24224:24224/udp"728x90
    
    
    
  Dockerfile 파일 생성
vim docker/Dockerfile#docker/Dockerfile
FROM fluent/fluentd:v1.12-debian
USER root
RUN apt-get update \
 && apt-get install -y --no-install-recommends $buildDeps \
 && gem install fluent-plugin-elasticsearch \
 && gem sources --clear-all \
 && rm -rf /var/lib/apt/lists/* \
 && rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem
USER fluentfluent.conf 파일 생성
vim docker/config/fluent.conf# fluentd/conf/fluent.conf
<source>
  @type  forward
  @id    input1
  @label @mainstream
  port  24224
</source>
<filter **>
  @type stdout
</filter>
<label @mainstream>
  <match docker.**>
    @type file
    @id   output_docker1
    path         /fluentd/log/docker.*.log
    symlink_path /fluentd/log/docker.log
    append       true
    time_slice_format %Y%m%d
    time_slice_wait   1m
    time_format       %Y%m%dT%H%M%S%z
  </match>
  <match **>
    @type file
    @id   output1
    path         /fluentd/log/data.*.log
    symlink_path /fluentd/log/data.log
    append       true
    time_slice_format %Y%m%d
    time_slice_wait   10m
    time_format       %Y%m%dT%H%M%S%z
  </match>
</label>docker-compose up -d
728x90
    
    
  반응형
    
    
    
  '리눅스' 카테고리의 다른 글
| systemd의 로깅 설정을 변경하기 (0) | 2023.02.26 | 
|---|---|
| td-agent plugin(out_fluentd 플러그인) (0) | 2023.02.22 | 
| SecureCRT에서 SSH 키 교환 알고리즘 설정과 관련된 오류 (0) | 2023.02.20 | 
| ubuntu 환경에서 elasticsearch와 kibana를 설치하는 방법 (0) | 2023.02.20 | 
| unable to resolve host hostname 오류 (0) | 2023.02.20 | 
 
                  
                 
                  
                 
                  
                