25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

Need help?

Our experts have had an average response time of 11.43 minutes in March 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Send Container Logs to Multiple Destinations in ECS

by | Aug 18, 2021

Generally, an Amazon ECS task definition allows us to specify a single log configuration object for a given container. However, to send Container Logs to Multiple Destinations in ECS, we can use FireLens.

Here, at Bobcares, we assist our customers with several AWS queries as part of our AWS Support Services.

Today. let us see methods to send Container Logs to Multiple Destinations.

 

Send Container Logs to Multiple Destinations in ECS

FireLens creates a configuration file on your behalf, but you can also specify a custom configuration file.

We can host this configuration file in either Amazon Simple Storage Service (Amazon S3), or create a custom Fluent Bit Docker image with the custom output configuration file added to it.

Moving ahead, let us see how our Support Techs perform this query for our customers.

Create AWS Identity and Access Management (IAM) permissions

To allow the task role to route the logs to different destinations, we need to create IAM permissions.

For example, suppose the destination is Kinesis Data Firehose. Then we give the task permission to call the firehose:PutRecordBatch API.

Create a Fluent Bit Docker image with a custom output configuration file

1. We need to create a custom Fluent Bit configuration file, logDestinations.conf with our choice of [OUTPUT] definitions defined in it.

For example, here have configurations defined for CloudWatch, Kinesis Data Firehose, and Splunk.

[OUTPUT]
Name firehose
Match YourContainerName*
region us-west-2
delivery_stream nginx-stream
[OUTPUT]
Name cloudwatch
Match YourContainerName*
region us-east-1
log_group_name firelens-nginx-container
log_stream_prefix from-fluent-bit
auto_create_group true
[OUTPUT]
Name splunk
Match *
Host 127.0.0.1
Splunk_Token xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx
Splunk_Send_Raw On

2. Then we create a Docker image with a custom Fluent Bit output configuration file like the following:

FROM amazon/aws-for-fluent-bit:latest
ADD logDestinations.conf /logDestinations.conf

3. With this Dockerfile we then create the custom fluent-bit Docker image. To do so, we run:

docker build -t custom-fluent-bit:latest .

We ensure to run the docker build command in the same location as the Dockerfile.

4. To confirm that the Docker image is available to Amazon ECS, we push the Docker image to Amazon ECR or our own Docker registry.

For example, to push a local Docker image to Amazon ECR, we run:

docker push aws_account_id.dkr.ecr.region.amazonaws.com/custom-fluent-bit:latest

5. After that, in the task definition (TaskDefinition), we update the options for the FireLens configuration. For example:

{
"containerDefinitions":[
{
"essential":true,
"image":"aws_account_id.dkr.ecr.region.amazonaws.com/custom-fluent-bit:latest",
"name":"log_router",
"firelensConfiguration":{
"type":"fluentbit",
"options":{
"config-file-type":"file",
"config-file-value":"/logDestinations.conf"
}
}
}
]
}

While on it, we need to consider the following:

We need to specify a custom configuration file, include the config-file-type and config-file-value options in the FireLens configuration file.

Then we must modify the image property in the containerDefinition section of the configuration to reflect a valid Amazon ECR image location.

To specify images in Amazon ECR repositories we can use the full registry/repository:tag naming convention.

For example,

aws_account_id.dkr.ecr.region.amazonaws.com/custom-fluent-bit:latest

[Stuck in between? We’d be happy to assist]

 

Conclusion

In short, we saw how our Support Techs Send Container Logs to Multiple Destinations in ECS.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF