Kubernetes

AWS Fluent Bit error 수정

DevelopC 2023. 3. 14. 20:38
728x90

 AWS Fluent Bit error 수정

AWS EKS에서 AWS CloudWatch로 로그를 전송하기 위해 AWS-Fluent-Bit Daemonset을 사용하고 있습니다.  어느 날 확인해 보니 AWS-Fluent-Bit POD에서 아래의 로그와 같이 caught signal (SIGSEGV) 에러가 나오고 POD 재시작이 되는 현상이 생각보다 자주 발생하고 있었습니다.

2023-01-10T07:01:14.243917003Z [2023/01/10 07:01:14] [ info] [filter:kubernetes:kubernetes.0]  token updated
2023-01-10T07:01:14.341788933Z [2023/01/10 07:01:14] [ info] [input:tail:tail.0] inotify_fs_add(): inode=143747423 watch_fd=83 name=/var/log/containers/nginx-kd39d19d2-polme_nginx_nginx-kbuim8cbdy3hmzyb3ggtirh3x76dedvkmbat68h2bnvx62jz35bwr3jipgbi6vd9.log
2023-01-10T07:01:14.342409507Z [2023/01/10 07:01:14] [ info] [input:tail:tail.0] inotify_fs_add(): inode=172019479 watch_fd=84 name=/var/log/containers/nginx-kd39d19d2-polme_nginx_nginx-b4pfjf6addaeqjq9vkj7acx4y4kgeymkd9eym34ve75m9cqwemcfvbz5fyw7x3tm.log
2023-01-10T07:01:14.359607654Z [2023/01/10 07:01:14] [2023/01/10 07:01:14] [error] [http_client] broken connection to logs.ap-northeast-2.amazonaws.com:443 ?
2023-01-10T07:01:14.359668464Z [2023/01/10 07:01:14] [error] [tls] error: error:00000005:lib(0):func(0):DH lib
2023-01-10T07:01:14.359699380Z [2023/01/10 07:01:14] [error] [src/flb_http_client.c:1189 errno=25] Inappropriate ioctl for device
2023-01-10T07:01:14.359734003Z [2023/01/10 07:01:14] [error] [output:cloudwatch_logs:cloudwatch_logs.1] Failed to send log events
2023-01-10T07:01:14.359771580Z [2023/01/10 07:01:14] [error] [output:cloudwatch_logs:cloudwatch_logs.1] Failed to send log events
2023-01-10T07:01:14.359797395Z [2023/01/10 07:01:14] [error] [output:cloudwatch_logs:cloudwatch_logs.1] Failed to send events
2023-01-10T07:01:14.359868264Z [engine] caught signal (SIGSEGV)

 

우선 위의 문제를 해결하기 위해 cpu/memory limit을 수정하였습니다. 수정하기 전에는 cpu 100m, memory 200Mi 설정하였고, cpu 200m, memory 256Mi로 수정하였습니다. 수정 후 로그를 살펴보니 아래와 같이 로그유실이 된 흔적을 발견하였습니다.

[2023/01/10 08:11:36] [ warn] [engine] chunk '1-1645042288.260516436.flb' cannot be retried: task_id=0, input=tcp.3 > output=cloudwatch_logs.1

aws-fluent-bit 디버깅 문서를 보면 cannot be retried 로그는 실제로 로그가 유실되었다는 로그라는 걸 확인할 수 있습니다. 로그 유실을 막기 위해 Retry_Limit 설정을 추가하였습니다. Retry_Limit 설정하지 않으면 기본값이 1 이므로 한번만 재전송시도하고, 그 한 번마저 재전송이 실패하면 로그를 CloudWatch로 전송되지 않고 유실됩니다. 그래서 재시도를 여러 번 할 수 있게 3으로 수정하였습니다.

Retry_Limit 설정을 추가한 후 cannot be retried 로그매세지는 발견되지 않았습니다. 하지만 아래의 overlimit 메세지를 발견하였습니다.

[input] tail.1 paused (mem buf overlimit)
[input] tail.1 paused (storage buf overlimit
[input] tail.1 resume (mem buf overlimit)
[input] tail.1 resume (storage buf overlimit

aws-fluent-bit 디버깅 문서를 보면 overlimit 메세지에 대한 방법이 설명되어있습니다. Mem_Buf_Limit 를 기존 설정의 2배씩 설정하였습니다. 설정 후 overlimit 로그메세지는 발견되지 않았습니다.

 

cpu/memory limit 변경 및 Retry_Limit / Mem_Buf_Limit 설정을 변경하니 caught signal (SIGSEGV) 에러로 POD이 재시작되지않았습니다. 

 

 

 

728x90