How to ingest ECS Log into OpenSearch (CLO) v2.0.0 #193
Replies: 1 comment
-
In the following guide, we will config the AWS FileLens and Centralized Logging with OpenSearch to collect the application log. Step 1 - Using FireLens to send logs to S31. Add the required policyAdd Create Log group policy to your ECS Task execution role {
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "logs:CreateLogGroup",
"Resource": "*"
}
]
} Add S3 putObject policy to your ECS Task role, please replace YOUR_BUCKET_NAME {
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": "s3:PutObject",
"Resource": [
"arn:aws:s3:::YOUR_BUCKET_NAME",
"arn:aws:s3:::YOUR_BUCKET_NAME/*"
]
}
]
} 2. Create a new version for your Task DefinitionWe recommend to use Create revision with JSON mode, and please modify the What we will do:
Please replace the following parameters in your task definition:
"containerDefinitions": [
{
"name": "app",
"image": "httpd",
"cpu": 0,
"portMappings": [
{
"name": "app-80-tcp",
"containerPort": 80,
"hostPort": 80,
"protocol": "tcp",
"appProtocol": "http"
}
],
"essential": true,
"environment": [],
"environmentFiles": [],
"mountPoints": [],
"volumesFrom": [],
"ulimits": [],
"logConfiguration": {
"logDriver": "awsfirelens",
"options": {
"Name": "s3",
"bucket": "YOUR_LOG_BUCKET_NAME",
"region": "YOUR_LOG_BUCKET_REGION",
"retry_limit": "2",
"s3_key_format": "/YOUR_S3_LOG_PREFIX/fluent-bit-logs/%Y/%m/%d/%H-%M-%S",
"total_file_size": "1M",
"upload_timeout": "1m",
"use_put_object": "On"
}
}
},
{
"name": "log_router",
"image": "amazon/aws-for-fluent-bit:stable",
"cpu": 0,
"memoryReservation": 50,
"portMappings": [],
"essential": true,
"environment": [],
"mountPoints": [],
"volumesFrom": [],
"user": "0",
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-create-group": "true",
"awslogs-group": "firelens-container",
"awslogs-region": "YOUR_CURRENT_REGION",
"awslogs-stream-prefix": "firelens"
}
},
"firelensConfiguration": {
"type": "fluentbit"
}
}
], 3. Using new Task Definition to update your ECS task or service.You can see the log in your s3 bucket. You can debug the FireLens in Task → Logs page, if you encounter any issues. Step 2 - Config the CLO S3 connector1. Create a Json Log ConfigIn this guidance, we use Apache log as example. If your log are in different format, please refer to Log Config documentation to create corresponding log config. Sample Log:
Time format
Timezone
2. Open CLO portal and create a S3 connector pipeline
3. Create the index patternAfter the pipeline is created, we need to go to OpenSearch Dashboard to create the index pattern. 4. Search the log in Discover pageYou now should be able to view the logs from ECS tasks in the Discovery of OpenSearch Dashboard. LimitationThis guide does not include log parsing using custom regex. If you want to parse the log by custom regex, please refer to: https://github.com/aws/aws-for-fluent-bit/blob/mainline/troubleshooting/debugging.md#tutorial-replicate-an-ecs-firelens-task-setup-locally Referencehttps://github.com/aws-samples/amazon-ecs-firelens-examples/tree/mainline/examples/fluent-bit/s3 |
Beta Was this translation helpful? Give feedback.
-
This doc provides guidance of using Centralized Logging with OpenSearch (CLO) to collect logs from Elastic Container Service (ECS) into OpenSearch.
Beta Was this translation helpful? Give feedback.
All reactions