gliderlabs / logspout

Log routing for Docker container logs
MIT License
4.66k stars 681 forks source link

documentation update for swarm #440

Open sandys opened 5 years ago

sandys commented 5 years ago

the docker template tags for swarm and compose are fairly different. it took my quite a while to figure out.

the source documentation is here - https://docs.docker.com/engine/reference/commandline/service_create/#create-services-using-templates

a working, reasonable logspout configuration for swarm is


  logspout:
    image: gliderlabs/logspout:latest
    networks:
      - logging
    volumes:
      - /etc/hostname:/etc/host_hostname:ro
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - SYSLOG_TAG="{{index .Service.Name}}"
      - SYSLOG_HOSTNAME="{{index .Node.Hostname}}"
      - INACTIVITY_TIMEOUT=1m
      - BACKLOG=false
      - SYSLOG_STRUCTURED_DATA="logdna@48950 key=\"12345\" tag=\"swarm,stacks\""
      - LOGSPOUT=ignore
    command:
      multiline+syslog+tls://syslog-a.logdna.com:44533
    deploy:
      mode: global
      resources:
        limits:
          cpus: '0.20'
          memory: 50M
        reservations:
          cpus: '0.10'
          memory: 50M```
niklas-dahl commented 4 years ago

I have a problem using this config, {{index .Service.Name}} resolves to the logspout service name, I want to tag every log entry with the service name of the container that created the log. Any advise?