|
1 | 1 | # aws-for-fluent-bit-config-from-env
|
2 | 2 | AWS FireLens Fluent Bit image with an option to provide a custom config as an environment variable (`FLUENT_BIT_CONFIG_BASE64`) in base64 format
|
| 3 | + |
| 4 | +This customization won't be needed if either https://github.com/aws/containers-roadmap/issues/56 or https://github.com/aws/aws-for-fluent-bit/issues/521 is resolved |
| 5 | + |
| 6 | +## Build and push |
| 7 | + |
| 8 | +``` |
| 9 | +# Set vars |
| 10 | +aws_region=REGION |
| 11 | +ecr_domain="AWS_ACCOUNT_ID.dkr.ecr.$aws_region.amazonaws.com" |
| 12 | +docker_image="$ecr_domain/custom-fluent-bit:latest" |
| 13 | +
|
| 14 | +# Build |
| 15 | +docker build -t "$docker_image" . |
| 16 | +
|
| 17 | +# Push |
| 18 | +aws ecr get-login-password --region "$aws_region" | docker login --username AWS --password-stdin "$ecr_domain" |
| 19 | +docker push "$docker_image" |
| 20 | +``` |
| 21 | + |
| 22 | +## Task definition example |
| 23 | + |
| 24 | +``` |
| 25 | +{ |
| 26 | + "family": "firelens-example-cloudwatch_logs", |
| 27 | + "taskRoleArn": "arn:aws:iam::AWS_ACCOUNT_ID:role/ecs_task_iam_role", |
| 28 | + "executionRoleArn": "arn:aws:iam::AWS_ACCOUNT_ID:role/ecs_task_execution_role", |
| 29 | + "networkMode": "awsvpc", |
| 30 | + "cpu": "256", |
| 31 | + "memory": "512", |
| 32 | + "requiresCompatibilities": [ |
| 33 | + "FARGATE" |
| 34 | + ], |
| 35 | + "containerDefinitions": [ |
| 36 | + { |
| 37 | + "essential": true, |
| 38 | + "name": "app", |
| 39 | + "image": "nginx", |
| 40 | + "logConfiguration": { |
| 41 | + "logDriver": "awsfirelens" |
| 42 | + }, |
| 43 | + "memoryReservation": 100 |
| 44 | + }, |
| 45 | + { |
| 46 | + "essential": true, |
| 47 | + "name": "log_router", |
| 48 | + "image": "AWS_ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/custom-fluent-bit:latest", |
| 49 | + "command": [ |
| 50 | + "/entrypoint_config_from_env.sh" |
| 51 | + ], |
| 52 | + "firelensConfiguration": { |
| 53 | + "type": "fluentbit", |
| 54 | + "options": { |
| 55 | + "config-file-type": "file", |
| 56 | + "config-file-value": "/fluent-bit/configs/config-from-env.conf" |
| 57 | + } |
| 58 | + }, |
| 59 | + "logConfiguration": { |
| 60 | + "logDriver": "awslogs", |
| 61 | + "options": { |
| 62 | + "awslogs-group": "firelens-container", |
| 63 | + "awslogs-region": "REGION", |
| 64 | + "awslogs-create-group": "true", |
| 65 | + "awslogs-stream-prefix": "firelens" |
| 66 | + } |
| 67 | + }, |
| 68 | + "environment": [ |
| 69 | + { |
| 70 | + "name": "FLUENT_BIT_CONFIG_BASE64", |
| 71 | + "value": "W09VVFBVVF0KICAgIE5hbWUgY2xvdWR3YXRjaF9sb2dzCiAgICBNYXRjaCAqCiAgICByZWdpb24gJHtGTFVFTlRfQklUX0xPR19SRUdJT059CiAgICBsb2dfa2V5IGxvZwogICAgbG9nX2dyb3VwX25hbWUgJHtGTFVFTlRfQklUX0xPR19HUk9VUH0KICAgIGxvZ19zdHJlYW1fcHJlZml4ICR7RkxVRU5UX0JJVF9MT0dfU1RSRUFNX1BSRUZJWH0KICAgIGF1dG9fY3JlYXRlX2dyb3VwIE9uCg==" |
| 72 | + }, |
| 73 | + { |
| 74 | + "name": "FLUENT_BIT_LOG_REGION", |
| 75 | + "value": "REGION" |
| 76 | + }, |
| 77 | + { |
| 78 | + "name": "FLUENT_BIT_LOG_GROUP", |
| 79 | + "value": "fluent-bit-cloudwatch" |
| 80 | + }, |
| 81 | + { |
| 82 | + "name": "FLUENT_BIT_LOG_STREAM_PREFIX", |
| 83 | + "value": "from-fluent-bit-" |
| 84 | + } |
| 85 | + ], |
| 86 | + "memoryReservation": 50 |
| 87 | + } |
| 88 | + ] |
| 89 | +} |
| 90 | +``` |
0 commit comments