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 or 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 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="CONTAINER-NAME" \ -e FILTER_LABELS="COMMA-SEPARATED-LABELS" \ -e HOSTNAME="ALTERNATIVE-HOSTNAME" \ -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="CONTAINER-NAME (Optional)" - FILTER_LABELS="COMMA-SEPARATED-LABELS (Optional)" - HOSTNAME="ALTERNATIVE-HOSTNAME (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=<CONTAINER-NAME (Optional)> - FILTER_LABELS=<COMMA-SEPARATED-LABELS (Optional)> - HOSTNAME=<ALTERNATIVE-HOSTNAME (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 2 days ago