본문 바로가기

인프라,데이터/Fluentd, Fluent Bit

(12)
Kubernetes 환경에서 Fluent Bit의 신뢰성 (tail input, s3 output) Fluent Bit를 테스트하고 로그 수집을 할 때 진작 이 수준으로 깊게 알았어야 했는데... 오늘에야 알게 된 내용 정리 1. Fluent Bit가 롤링 업데이트 되어도 Input 과정에서 로그 손실이 없을까? - Tail Input을 사용할 경우 fluent bit을 배포하기 위해 사용한 Daemonset은 기본적으로 노드별로 pod를 rolling update ** 현재 daemonset은 먼저 기존 pod를 삭제하고 새 pod를 생성함에 유의 ** fluent-bit-configmap.yaml [INPUT] Name tail Tag test.* Path /var/log/containers/test*.log DB /var/log/flb_test.db fluent bit는 input 플러그인에서 D..
Fluentd tail input 로그 1개 손실 & 로그 느리게 들어오는 이유 해결 한줄요약 : multiline 때문입니다. multiline_flush_interval 옵션을 사용하면 해결됩니다. Fluentd로 로그를 수집하는데, 초당 로그를 일정하게 발생시키는 스크립트를 짜고 로그 수집을 테스트해보는데 왜인지 테스트 할때마다 로그가 1개씩 덜 들어왔다. 왜 그러지..? 싶었으나 원인을 쉽게 찾을 수 없었다. 그리고 Kinesis output을 사용할 때, 로그가 1초에 여러번 들어오면 '로그 발생 -> Kinesis -> ES 적재'까지 몇 초 내로 적재되었으나 로그를 1분에 한 번 꼴로 발생시킬 경우 '로그 발생 -> Kinesis -> ES 적재'까지 60초 + flush interval에 해당하는 시간이 걸렸다. (여기서 알아챘어야 했다.. ㅎㅎ) 왜 위의 두가지 현상이 발..
Fluentd로 S3 output path에 field(key) 값 넣기 {"filename":"test.log"} 와 같은 데이터가 있을 때, Fluentd를 사용해서 "filename" 키의 값에 해당하는 "test.log"를 s3으로 보내는 경로에 넣어주고 싶다면 어떻게 해야 할까요? 먼저 rewrite_tag_filter를 사용해서 필요한 key 값들을 tag에 추가해 줍니다. @type rewrite_tag_filter key instance_name pattern ^(.+)$ tag s3_mid.$1 @type rewrite_tag_filter key filename pattern ^(.+)$ tag s3.${tag}.$1 저는 path에 key를 2개 넣어야 해서 필터를 2번 사용해 줬습니다. 처음엔 한 번에 2개의 rule을 사용하면 안 될까? 했는데 안 됩니다..
Fluentd add Record Field by Ruby 'Case when~' Conditional Statements I used to config logstash with something like this : mutate { copy => {"test" => "test_s3path"} } if [test_s3path] =~ /^A-/ { mutate { update => { "test_s3path" => "A-INSTANCES" } } } else if [test_s3path] =~ /^B-/ { mutate { update => { "test_s3path" => "B-INSTANCES" } } } else if [test_s3path] =~ /^C-/ { mutate { update => { "test_s3path" => "C-INSTANCES" } } } else if [test_s3path] =~ /^D-/ {..
argocd 로그 모니터링 argocd 에서 애플리케이션 배포시 생기는 로그를 수집했어야 했는데, 파싱이나 설정 부분에서 좀 헤맸던 면이 있어 기록으로 남긴다..! Fluent Bit conf [INPUT] Name tail Tag syslog.* Path /var/log/containers/*.log storage.type filesystem Parser docker DB /var/log/sys_kube.db Refresh_Interval 10 Path_Key path /var/log/containers/~ 하위에 쌓이는 모든 로그를 syslog란 태그로 수집한다. [FILTER] Name rewrite_tag Match syslog.* Rule $kubernetes['namespace_name'] ^(argocd)$ argoc..
Fluent Bit에 SQS Output 연결하기(feat. Golang) Fluent Bit에는 공식 SQS Output 플러그인이 없다. https://github.com/PayU/fluentBit-sqs-plugin GitHub - PayU/fluentBit-sqs-plugin: FluntBit custom output plugin which allows sending messages to AWS-SQS. FluntBit custom output plugin which allows sending messages to AWS-SQS. - GitHub - PayU/fluentBit-sqs-plugin: FluntBit custom output plugin which allows sending messages to AWS-SQS. github.com 하여 위의 플러그인을 이용한..
Fluent Bit의 버퍼링Buffering (번역) Fluent Bit의 공식 문서에서 버퍼링과 스토리지, 백프레셔에 관해 번역한 글입니다. 백프레셔 Fluent Bit의 목표는 중앙으로 로그를 모으고, 파싱하고, 필터링하고, 적재하는 것입니다. 이 과정에서 처리할 새로운 데이터를 받는데, 데이터를 빠르게 전송하지 못한다면 백프레셔backpressure를 마주하게 됩니다. 특정한 환경에서는 로그나 데이터가 목적지로 보낼 수 있는 여력보다 빠르게 유입됩니다. 흔한 케이스로는 큰 로그 파일을 읽어오고 네트워크를 통해 백엔드로 보내는 것이 있는데, 응답하기까지 시간이 걸리고, 이것은 서비스에서 큰 메모리 소모를 야기하는 백프레셔를 생성하게 됩니다. 버퍼링 Fluent Bit는 버퍼링으로 백프레셔와 일반적인 전송 실패 문제를 풀고자 합니다. 버퍼링은 데이터가 적..
Using Lua filter to find if log matches a pattern, and remove last n characters. Original log: [1646213018.112301921, {"log"=>"testtest1-"} Changed log : [1646213018.112301921, {"log"=>"testtest1"} [FILTER] Name lua Match test.* script checkend.lua call check_end If you use lua filter, you can find "If a log/word matches a specific pattern", and do some works. ex) if the condition suits, remove last n characters. I wrote on those codes on fluentbit configmap, so there is tab..