Docker Logs

Here are setup instructions for a variety of Docker platforms including Docker Cloud, ECS, and Rancher.

Overview

Log data can be forwarded from a variety of Docker-based platforms to LogDNA. However, the setup instructions for each platform may be different. LogDNA currently supports logging from Docker, Docker Cloud, ECS, and Rancher.

LogDNA Docker integrations rely on LogSpout, a log router for Docker containers.

Docker

  1. You can do so from the Docker section of the add log source instructions modal available in the LogDNA web app.

  2. Run the following LogSpout command:

sudo docker run --name="logdna" --restart=always \
-d -v=/var/run/docker.sock:/var/run/docker.sock \
-e LOGDNA_KEY="YOUR-INGESTION-KEY (Required)" \
-e HOSTNAME="ALTERNATIVE-HOSTNAME (Optional)" \
-e TAGS="docker" \
logdna/logspout:latest

Note: if you run into permission issues, try to run it as a root.

Pro tip: You can change the default docker host tag to any string you like, and even use multiple tags by separating them with a comma (,).

Docker Cloud

Append the following to your Docker Cloud stackfile:

logdna:
  autoredeploy: true
  deployment_strategy: every_node
  environment:
    - LOGDNA_KEY="YOUR-INGESTION-KEY (Required)"
    - HOSTNAME='{{index .Container.Config.Labels "com.docker.compose.project"}}'
    - TAGS='{{.Container.Config.Hostname}}'
  image: 'logdna/logspout:latest'
  restart: always
  volumes:
    - '/var/run/docker.sock:/var/run/docker.sock'

Note: if you run into permission issues, try to run it as a root.

Pro tip: You can change the default docker host tag to any string you like, and even use multiple tags by separating them with a comma (,).

Elastic Container Service (ECS)

Append the following to your ECS cloud configuration:

services:
  logspout:
    environment:
        - LOGDNA_KEY="YOUR-INGESTION-KEY (Required)"
        - TAGS='{{ if .Container.Config.Labels }}{{index .Container.Config.Labels "com.amazonaws.ecs.task-definition-family"}}:{{index .Container.Config.Labels "com.amazonaws.ecs.container-name"}}{{ else }}{{.ContainerName}}{{ end }}'
    image: logdna/logspout:latest
    restart: always
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    deploy:
      mode: global

Note: if you run into permission issues, try to run it as a root.

Pro tip: You can change the default docker host tag to any string you like, and even use multiple tags by separating them with a comma (,).

Rancher

  1. Create a LogDNA stack from the Rancher compose file below.
version: '2'
services:
  logdna:
    image: logdna/logspout:latest
    environment:
      LOGDNA_KEY="YOUR-INGESTION-KEY (Required)"
    restart: always
    labels:
      io.rancher.container.hostname_override: container_name
      io.rancher.container.pull_image: always
      io.rancher.os.scope: system
    volumes:
    - /var/run/docker.sock:/tmp/docker.sock
  1. Once created, add the following environment variables under the Command section of the Rancher web interface.
HOSTNAME = {{ index .Container.Config.Labels "io.rancher.container.name" }}
TAGS = {{ index .Container.Config.Labels "io.rancher.stack_service.name" }}

Note: if you run into permission issues, try to run it as a root.

Pro tip: You can change the default docker host tag to any string you like, and even use multiple tags by separating them with a comma (,).

Docker Swarm

Append the following to your Docker Swarm compose file:

version: '3'
networks:
- logging:
    services:
      logdna:
        image: logdna/logspout:latest
        volumes:
        - /var/run/docker.sock:/var/run/docker.sock
        environment:
        - LOGDNA_KEY="YOUR-INGESTION-KEY (Required)"

Note: if you run into permission issues, try running this as root by inserting user: root under the logdna service object.

Pro tip: You can change the default docker host tag to any string you like, and even use multiple tags by separating them with a comma (,).

Docker Logs

Here are setup instructions for a variety of Docker platforms including Docker Cloud, ECS, and Rancher.