This setup adapts Papertrail’s Docker logspout instructions for Amazon ECS. Logspout is a lightweight log router for Docker.
Create a task definition
- Open the Amazon ECS console.
- If multiple regions are available, from the navigation bar, select the region in which to register your task definition.
- In the left sidebar, select Task Definitions, and click Create new Task Definition.
- Enter a name for the definition (for example,
- Click Add volume.
- In the Add volume dialog, name the volume (for example,
dockersock) and enter
/var/run/docker.sock as the Source path.
- Click Add.
- Under Container Definitions, click Add container.
- Enter the container details in the Add container dialog:
- Provide a Container name (such as
- For Image, enter
- In Advanced Container Configuration, under ENVIRONMENT, enter
syslog://logsN.papertrailapp.com:XXXXX as the Command value, replacing
XXXXX with details from the Papertrail log destination:
To use TCP/TLS, use
syslog+tls as the protocol.
- Under STORAGE AND LOGGING > Mount points, select the docker socket volume name as the Source volume, and enter
/tmp/docker.sock as the Container path:
- Click Add.
- Click Create to create the task definition.
Create a service using the task
- If coming from the Task Definition name page, first select the revision of the task definition to use to create your service.
- Review and click Actions > Create Service.
- Fill in the service fields, with Number of Tasks being 1. Provide a name (such as
logspout) and other values based on the desired cluster setup.
- Select One Task per Host for Placement Templates. This sets up one logspout container per instance, to prevent log duplication.
- Review other settings, and click Create Service.
There’s now a logspout container running, ready to accept logs from your other containers and send them to Papertrail.
Configure containers to log through logspout
For each container that should log through logspout:
- Access the container’s task definition.
- Select Actions > Create New Revision.
- Click the container’s name.
- In the Edit Container dialog, under STORAGE AND LOGGING > Log configuration, set Log driver to either
- Click Update.
- On the revision screen, click Actions > Update Service to update the service to the new task definition version.
Once the services are updated, visit the Event viewer to see logs come in.