본 글은 https://docs.fluentd.org/을 번역/요약/정리/사견 추가한 글입니다.
1. 도입
Fluentd는 9가지 종류의 플러그인이 있습니다. 그 중 output 플러그인에 대해 살펴보겠습니다.
Fluentd v1.0 output 플러그인은 3가지 모드가 있습니다.
- Non-buffered mode - 데이터를 버퍼에 넣지 않고 바로 쓰는 모드
- Synchronous Buffered mode - buffer chunk들(이벤트들의 집합)에 이벤트들을 넣은 후, 큐에 chunk를 하나씩 넣고 빼내 chunk를 쓰는 모드
- Asynchronous Buffered mode - buffer chunk, queue는 있지만 output plugin은 chunk를 쓰지 않고 나중에 쓰는 모드?
output 플러그인들은 3개 모두 지원할 수도 있지만 주로는 1개만 지원합니다. 만약 설정에 <buffer> 섹션이 없다면 Fluentd는 가장 적절한 모드를 자동 선택합니다. 만약 사용자가 해당 플러그인이 지원하지 않는 모드를 <buffer>에 넣으면 에러를 일으킵니다.
2. out_file
out_file은 이벤트를 파일에 씁니다. 하루마다 파일을 새로 만들어 기록합니다.
<match pattern>
@type file
path /var/log/fluent/myapp
compress gzip
<buffer>
timekey 1d
timekey_use_utc true
timekey_wait 10m
</buffer>
</match>
3. out_forward
out_forward는 다른 fluentd 노드로 이벤트를 보냅니다.
<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>
4. out_http
out_http는 HTTP/HTTPS를 이용해 레코드를 씁니다.
<match pattern>
@type http
endpoint http://logserver.com:9000/api
open_timeout 2
<format>
@type json
</format>
<buffer>
flush_interval 10s
</buffer>
</match>
5. out_exec
out_exec은 외부 프로그램으로 이벤트를 넘깁니다. 프로그램은 이벤트를 담고 있는 파일의 경로를 마지막 인자로 받습니다.
<match pattern>
@type exec
command cmd arg arg
<format>
@type tsv
keys k1,k2,k3
</format>
<inject>
tag_key k1
time_key k2
time_format %Y-%m-%d %H:%M:%S
</inject>
</match>
6. out_secondary_file
out_secondary_file은 chunks를 파일에 씁니다. out_file과 비슷하지만 이 플러그인은 <secondary>로 쓸 수 있고 이렇게 써야만 합니다. <secondary>는 부모 match의 output 플러그인이 이벤트를 쓰는데 실패했을 때 사용되는 플러그인을 명시할 수 있습니다.
<match pattern>
@type forward
# ...
<secondary>
@type secondary_file
directory /var/log/fluentd/error
</secondary>
</match>
7. out_copy
out_copy는 이벤트를 여러 개의 output에 복사합니다.
<match pattern>
@type copy
<store>
@type file
path /var/log/fluent/myapp1
...
</store>
<store>
@type elasticsearch
host fluentd
...
</store>
<store>
...
</store>
</match>
8. out_relabel
out_relabel은 이벤트의 레이블을 조정합니다.
<match pattern>
@type relabel
@label @foo
</match>
<label @foo>
<match pattern>
# ...
</match>
</label>
9. out_roundrobin
oput_roundrobin은 이벤트를 weighted round-robin 알고리즘을 이용해 여러 output으로 보냅니다.
<match pattern>
@type roundrobin
<store>
@type http
endpoint http://192.168.1.21
weight 3
# ...
</store>
<store>
@type http
endpoint http://192.168.1.22
weight 2
# ...
</store>
<store>
@type http
endpoint http://192.168.1.23
weight 1
# ...
</store>
</match>
'Log > fluentd' 카테고리의 다른 글
06. Fluentd parser plugins (0) | 2022.10.09 |
---|---|
05. Fluentd buffer plugins (0) | 2022.10.08 |
04. Fluentd filter plugins (0) | 2022.10.08 |
02. Fluentd input plugins (0) | 2022.10.08 |
01. Fluentd란? (1) | 2022.10.08 |