A
A
Anton Bes2020-01-29 10:08:56
graylog
Anton Bes, 2020-01-29 10:08:56

Why is the Docker container not sending logs?

Good day, there was such a problem. I raise a container on the server that should send logs to Graylog. The latter sees the connection perfectly, but it does not receive logs, what can be done about it?

docker_container:
    name: "{{ container_name }}"
    image: "{{ container_image }}"
    state: "{{ container_state | default('started') }}"
    log_driver: "{{ logdriver_type }}"
    log_options: "{{ options_on_logdriver }}"

  vars:
    container_name: nginx
    container_image: nginx:1.17.8
    list_of_deployment_configuration_paths:
       - ./:/etc/nginx/conf.d/
    logdriver_type: syslog
    options_on_logdriver:
      syslog-address: "tcp://ip:port"
      tag: myservice

This is how a piece of the ansible role looks like, with which I deploy it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Georg Gaal, 2020-02-02
@BSH_EYES

1. if you have a graylog - you can use the GELF driver
2. for the graylog to receive logs - you need to configure the so-called INPUT with the appropriate parameters - one, two - allow connections to them outside the firewall or, if the graylog is in the container, add the appropriate ports to the forwards
3. other things being equal, I recommend using the journald driver, because it does not break the docker logs command - it will be possible to look at the logs locally + it has a bunch of other things like rate limit, rotation and other things, which allows you to ensure the minimum impact of the logs on the host system. And from journald, you can set up forwarding to graylog - as a bonus, you will receive a message from the host machine itself (as if its logs are of no interest to anyone)

Similar questions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question