Infrastructure/Fluentd

[Fluentd] 5. Output plugin

상쾌한기분 2021. 5. 11. 14:47
반응형

Output Plugin

https://docs.fluentd.org/output

file

file 은 이름처럼 데이터를 파일로 생성

<match pattern>
  @type file
  path /var/log/fluent/myapp
  compress gzip
  <buffer>
    timekey 1d
    timekey_use_utc true
    timekey_wait 10m
  </buffer>
</match>

forward

output 에서 forward 는
local fluentd 데이터를 external fluentd 로 전송해 줌

아래 보면 myserver1과 myserver2 로 local event data를 전송해주고
운영시에 장애가 발생해도 문제 없이 운영이 가능 하도록 2개의 서버로 데이터를 보내는 것 유추 쌉가능

<match pattern>
  @type forward
  send_timeout 60s
  recover_wait 10s
  hard_timeout 60s

  <server>
    name myserver1
    host 192.168.1.3
    port 24224
    weight 60
  </server>
  <server>
    name myserver2
    host 192.168.1.4
    port 24224
    weight 60
  </server>
  ...

  <secondary>
    @type file
    path /var/log/fluent/forward-failed
  </secondary>
</match>

http

http 는 HTTP/HTTPS Domain 으로 데이터를 전송해 줌
method 는 post, put 을 제공하며, content-type 도 설정 가능하다

<match pattern>
  @type http

  endpoint http://logserver.com:9000/api
  open_timeout 2

  <format>
    @type json
  </format>
  <buffer>
    flush_interval 10s
  </buffer>
</match>

secondary_file

secondary_file 은 사용하는 output plugin 에서 혹시 몰라서 백업용으로 사용하는 plugin 이고, main 으로 사용하지 말라고 함

<match pattern>
  @type forward
  # ...
  <secondary>
    @type secondary_file
    directory /var/log/fluentd/error
  </secondary>
</match>

stdout

디버깅, 테스트 용으로 사용하면 됨
systemd 로 실행시키면 agent log 에 찍히고
직접 호출 실행을 하면 리눅스 화면에 로그가 찍힘

<match apps.**>
  @type stdout
</match>

이후 다른 flugin들에 대해서는 스스로 학습 하도록 하자
728x90
반응형