The LogDNA Docker container lets you send logs from Docker, Docker Cloud, Amazon Elastic Container Service (ECS), and other Docker-based platforms. The container automatically collects logs generated by other containers running on the host and sends them to LogDNA’s ingestion servers. The container is based on Logspout and supports custom metadata, such as a custom hostname and tags.
To learn how to send logs from orchestration tools like Kubernetes, Docker Swarm, and Rancher, see the Kubernetes documentation page.
As part of your container logging strategy, all of your containers should log to STDOUT and STDERR (standard output). Not only is this required for Logspout to work, but Docker itself expects containers to log to these outputs. Logging your containers to standard output is both a best practice and essential for the Logspout container to function.
To log a standard Docker deployment, deploy an instance of the Logspout container. Make sure to replace the following example values with your specific values (these also apply to all of the following deployment methods):
LOGDNA_KEY: Required. Your LogDNA ingestion key.
FILTER_NAME: Optional. The name of the specific container to monitor.
FILTER_LABELS: Optional. A comma-separated list of labels to use to filter specific containers.
HOSTNAME: Optional. An alternate hostname other than the one detected by the container.
TAGS: Optional. A comma-separated list of tags to apply to logs processed by this container.
sudo docker run --name=logdna --restart=always \ -d -v=/var/run/docker.sock:/var/run/docker.sock \ -e LOGDNA_KEY=<your_ingestion_key> \ -e FILTER_NAME=<name_of_container> \ -e FILTER_LABELS=<comma_separated_labels> \ -e HOSTNAME=<alternative_host_name> \ -e TAGS=<comma_separated_tags> \ logdna/logspout:latest
To log a Docker Cloud deployment, add the following to your stackfile:
logdna: autoredeploy: true deployment_strategy: every_node environment: - LOGDNA_KEY=<your_ingestion_key> (Required) - FILTER_NAME=<name_of_container> (Optional) - FILTER_LABELS=<comma_separated_labels> (Optional) - HOSTNAME=<alternative_host_name> (Optional) - TAGS=<comma_separated_tags> (Optional) image: logdna/logspout:latest restart: always volumes: - '/var/run/docker.sock:/var/run/docker.sock'
To deploy via Docker Compose, add the following to your Compose file:
services: logspout: environment: - LOGDNA_KEY=<your_ingestion_key> (Required) - FILTER_NAME=<name_of_container> (Optional) - FILTER_LABELS=<comma_separated_labels> (Optional) - HOSTNAME=<alternative_host_name> (Optional) - TAGS=<comma_separated_tags> (Optional) image: logdna/logspout:latest restart: always volumes: - /var/run/docker.sock:/var/run/docker.sock deploy: mode: global
This also applies to Docker services that support the Compose file syntax, such as Amazon Elastic Container Service (ECS).
Updated 6 months ago