question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatically refer to the appropriate, regional FireLens image with addFirelensLogRouter()

See original GitHub issue

The documentation suggests using Amazon’s own ECR images for the FireLens container. However, image is a required property.

It would be a nice convenience if CDK could determine the destination stack’s region and automatically use the proper ecr.Repository.fromRepositoryArn() behavior.

Use Case

Today, I can get this behavior manually, but I had to generate the reference myself:

// Amazon recommends pulling this image from their regional ECR repo
// https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_firelens.html#firelens-using-fluentbit
const awsEcrRepo = ecr.Repository.fromRepositoryArn(
  parent,
  "AWSFireLensRepo",
  "arn:aws:ecr:us-west-2:906394416424:repository/aws-for-fluent-bit",
);
taskDefinition.addFirelensLogRouter("DatadogFirelensLogRouter", {
  image: ecs.ContainerImage.fromEcrRepository(awsEcrRepo, "latest"),
  memoryReservationMiB: 50,
  essential: true,
  firelensConfig: {
    type: ecs.FirelensLogRouterType.FLUENTBIT,
    options: {
      enableECSLogMetadata: true,
      configFileType: ecs.FirelensConfigFileType.FILE,
      configFileValue: "/fluent-bit/configs/parse-json.conf",
    },
  },
});

Proposed Solution

Ideally, image on FirelensLogRouterDefinitionOptions is an optional parameter and defaults to the proper ECR image from this table in the docs.

Other

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rcollettecommented, Oct 11, 2020

The package @aws-cdk/aws-ecs exports the function obtainDefaultFluentBitECRImage. This will reference the appropriate regional image for fluent bit.

You can view usage here: https://stackoverflow.com/questions/64299664/how-to-configure-aws-cdk-applicationloadbalancedfargateservice-to-log-parsed-jso/

I will say that it takes a lot of discovery to figure out how to override the default logDriver to enable json line parsing. Definitely either more documentation or a simpler API would be helpful.

0reactions
PettitWesleycommented, Dec 7, 2022

Q: I can’t find any docs for obtainDefaultFluentBitECRImage.

So I think the AWS ECS FireLens constructs are supposed to live here now: https://github.com/cdklabs/cdk-ecs-service-extensions/

But then the function still seems to only be here: obtainDefaultFluentBitECRImage in this repo.

Are there no docs for this function? Or do I not know the right place to look? Is it not intended for end-user direct use?

https://github.com/cdklabs/cdk-ecs-service-extensions/issues/249

@SomayaB @uttarasridhar

Read more comments on GitHub >

github_iconTop Results From Across the Web

class FirelensLogRouter (construct) · AWS CDK
The working directory in which to run commands inside the container. firelensConfig. Type: FirelensConfig. Firelens configuration. image. Type: ...
Read more >
Creating a task definition that uses a FireLens configuration
To use custom log routing with FireLens , you must specify the following in your ... described in Amazon Web Services documentation might...
Read more >
AWS FireLens plugin for log forwarding
New Relic uses a Fluent Bit image to configure the FireLens log router container. This container handles all log routing from application plugins....
Read more >
aws_ecs_task_definition | Resources | hashicorp/aws
resource "aws_ecs_task_definition" "service" { family = "service" container_definitions = jsonencode([ { name = "first" image = "service-first" cpu = 10 ...
Read more >
Lab 2: Deploy Cluster - ECS_Fargate_Workshop
Using roughly 15 lines of Python code you can instantiate ECS Task (note task_image options describing image details, port mappings, logging setting and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found