인프라,데이터/Fluentd, Fluent Bit
Fluent Bit Stream Processor 사용하여 데이터 특정 조건에 따라 다른 아웃풋으로 보내기
AimB
2022. 1. 26. 18:06
fluent-bit.conf: |
[SERVICE]
Flush 5
Log_Level info
Daemon off
Parsers_File parsers.conf
Streams_File streams.conf
HTTP_Server On
HTTP_Listen 0.0.0.0
HTTP_Port 2020
먼저 [SERVICE]에 Streams_File 을 기재해줍니다.
streams.conf: |
[STREAM_TASK]
Name check_one
Exec CREATE STREAM three_check WITH (tag='userlog.*') AS SELECT * FROM TAG:'userlog.*' WHERE cluster_name = " " and pod_namespace = " " and pod_name = " ";
Tag hello
[STREAM_TASK]
Name check_two
Exec CREATE STREAM two_check_one WITH (tag='userlog.*') AS SELECT * FROM TAG:'userlog.*' WHERE cluster_name = " " and pod_namespace = " " and pod_name != " ";
Tag bye
streams.conf 파일에서
Name : Stream의 이름
Exec : 실행할 SQL문
Tag : SQL의 실행 결과 나오는 로그들을 묶을 태그
를 지정해줍니다.
output-s3.conf: |
[OUTPUT]
Name s3
Match hello
bucket dev-xx-test
region ap-northeast-2
s3_key_format /fluent-bit/hello/%Y/%m/%d/$UUID.gz
s3_key_format_tag_delimiters .
upload_timeout 30m
[OUTPUT]
Name s3
Match bye
bucket dev-xx-test
region ap-northeast-2
s3_key_format /fluent-bit/bye/%Y/%m/%d/$UUID.gz
s3_key_format_tag_delimiters .
upload_timeout 30m
Match -> 아까 기재한 태그를 적어두면
Tag에 따라 다른 output으로 보낼 수 있습니다.