Home:ALL Converter>How to collect logs via fluentd in swarm mode

How to collect logs via fluentd in swarm mode

Ask Time:2018-05-11T02:25:55         Author:zella

Json Formatter

I try to run services (mongo) in swarm mode with log collected to elasticsearch via fluentd. It's worked(!) with:

docker-compose up

But when I deploy via stack, services started, but logs not collected, and i don't know how to see what the reason.

docker stack deploy -c docker-compose.yml env_staging

docker-compose.yml:

version: "3"
services:
    mongo:
        image: mongo:3.6.3
        depends_on:
         - fluentd
        command: mongod
        networks:
         - webnet
        logging:
          driver: "fluentd"
          options:
            fluentd-address: localhost:24224
            tag: mongo
    fluentd:
        image: zella/fluentd-es
        depends_on:
         - elasticsearch
        ports:
         - 24224:24224
         - 24224:24224/udp
        networks:
         - webnet
    elasticsearch:
        image: elasticsearch
        ports:
         - 9200:9200
        networks:
         - webnet
    kibana:
        image: kibana
        depends_on:
         - elasticsearch
        ports:
         - 5601:5601
        networks:
         - webnet
networks:
     webnet:

upd

I remove fluentd-address: localhost:24224 and problem solves. But I don't understand what is "localhost"? Why we can't set "fluentd" host. If someone explain what is fluentd-address, I will accept answer.

Author:zella,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/50279274/how-to-collect-logs-via-fluentd-in-swarm-mode
Nicola Ben :

fluentd-address is the address where fluentd daemon resides (default is localhost and you don't need to specify it in this case). \n\nIn your case (using stack) your fluentd daemon will run on a node, you should reach that service using the name of the service (in your case fluentd, have you tried?).\n\nRemember to add to your options the fluentd-async-connect: \"true\"\n\nReference is at: \nhttps://docs.docker.com/config/containers/logging/fluentd/#usage",
2018-05-13T19:16:27
yy