GuidesIntegrationsLogging with Firelens

Logging with Firelens

AWS Firelens is a log driver for ECS that increases your control over log routing and storage. A typical use case for Firelens is to route logs to a third-party service, such as Datadog. See the web service type docs for specific configuration information.

Firelens uses Fluent Bit plugins for sending logs to other services. This is an open source tool that contains a number of third party output plugins that can be used with Firelens. After configuring the third-party service, you can use the following templates to route logs to the service.

44+ Integrations

You can route logs to any Fluent Bit output plugin.

Configuration for common examples are listed here for easy reference:

Datadog Example

Add the following logging and envVariables fields in your Flightcontrol service config. Be sure to replace the values with the specific values for your Datadog instances.

See the Datadog documentation for more information.

{
  "$schema": "https://app.flightcontrol.dev/schema.json",
  "environments": [
    {
      "id": "production",
      "name": "Production",
      "region": "us-west-2",
      "source": {
        "branch": "main"
      },
      "services": [
        {
          "id": "my-webapp",
          "name": "My Webapp",
          "type": "web",
          "target": {"type": "fargate"},
          "buildType": "docker",
          "ci": {
            "type": "ec2"
          },
          "dockerfilePath": "Dockerfile",
          "dockerContext": ".",
          "cpu": 0.25,
          "memory": 0.5,
          "port": 8080,
          "minInstances": 1,
          "maxInstances": 1,
          "logging": {
            "ecsLogsMetadataEnabled": true,
            "firelensOptions": [
              {
                "name": "datadog",
                "match": "*",
                "options": {
                  "apikey": "${DATADOG_API_KEY}",
                  "Host": "http-intake.logs.us5.datadoghq.com",
                  "dd_service": "service name in Datadog",
                  "dd_source": "optional",
                  "dd_tags": "optional",
                  "TLS": "on",
                  "provider": "ecs"
                }
              }
            ],
            "envVariables": {
              "DATADOG_API_KEY": {
                "fromParameterStore": "/datadog/api"
              }
            }
          }
        }
      ]
    }
  ]
}