Search

AWS Docs Fluentbit Daemonset

ENV

EKS_CLUSTER_NAME="<CLUSTER_NAME>" DASHBOARD_NAME="<DASHBOARD_NAME>" REGION_CODE="<AWS_REGION>" EKS_NODE_GROUP_NAME="<NODE_GROUP_NAME>"
Shell
복사

Attach IAM Role for EKS NodeGroup

NODEGROUP_ROLE_NAME=$(aws eks describe-nodegroup --cluster-name $EKS_CLUSTER_NAME --nodegroup-name $EKS_NODE_GROUP_NAME --query "nodegroup.nodeRole" --output text | cut -d'/' -f2-)
Shell
복사
aws iam attach-role-policy \ --role-name $NODEGROUP_ROLE_NAME \ --policy-arn arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy
Shell
복사

Fluent Bit DaemonSet 배포를 위한 설정

ClusterName=$EKS_CLUSTER_NAME RegionName=$REGION_CODE FluentBitHttpPort='2020' FluentBitReadFromHead='Off' [[ ${FluentBitReadFromHead} = 'On' ]] && FluentBitReadFromTail='Off'|| FluentBitReadFromTail='On' [[ -z ${FluentBitHttpPort} ]] && FluentBitHttpServer='Off' || FluentBitHttpServer='On' kubectl create configmap fluent-bit-cluster-info \ --from-literal=cluster.name=${ClusterName} \ --from-literal=http.server=${FluentBitHttpServer} \ --from-literal=http.port=${FluentBitHttpPort} \ --from-literal=read.head=${FluentBitReadFromHead} \ --from-literal=read.tail=${FluentBitReadFromTail} \ --from-literal=logs.region=${RegionName} -n amazon-cloudwatch
Shell
복사
위 명령어를 파일로 작성한다면 아래와 같다.
apiVersion: v1 data: cluster.name: "cluster-name" logs.region: "cluster-region" http.server: "On" http.port: "2020" read.head: "Off" read.tail: "On" kind: ConfigMap metadata: name: fluent-bit-cluster-info namespace: amazon-cloudwatch
YAML
복사

Fluent Bit DaemonSet 배포

kubectl apply -f https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/latest/k8s-deployment-manifest-templates/deployment-mode/daemonset/container-insights-monitoring/fluent-bit/fluent-bit.yaml
Shell
복사

Fluent Bit daemonSet Pod가 실행 중인지 확인

kubectl get pods -n amazon-cloudwatch
Shell
복사

Fluent Bit Prometheus 지표에 대한 대시보드

curl https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/latest/k8s-deployment-manifest-templates/deployment-mode/service/cwagent-prometheus/sample_cloudwatch_dashboards/fluent-bit/cw_dashboard_fluent_bit.json \ | sed "s/{{YOUR_AWS_REGION}}/${REGION_CODE}/g" \ | sed "s/{{YOUR_CLUSTER_NAME}}/${EKS_CLUSTER_NAME}/g" \ | xargs -0 aws cloudwatch put-dashboard --dashboard-name ${DASHBOARD_NAME} --dashboard-body
Shell
복사