Docker container cannot send log to docker ELK stack

折月煮酒 提交于 2020-01-03 02:30:21

问题


I deployed ELK stack and another separated docker container of spring boot app.

In the java app, I use the LogstashSocketAppender to send logs to logstash.

  1. If the java app running standalone without docker, it works fine.
  2. But when it's running as a docker container, the logstash cannot receive logs.

Can anyone help me figure out it?

part of logstash configuration:

input {
    udp {
        port => 5000
        type => syslog
        codec => json
    }
}

dcoker port:

logstash$ 5000/udp -> 0.0.0.0:5000
springboot$ 8088/tcp -> 0.0.0.0:32981
elasticsearch$ 9200/tcp -> 0.0.0.0:9200 9300/tcp -> 0.0.0.0:9300
kibana$ 5601/tcp -> 0.0.0.0:5601

回答1:


You can get your container logs by configuring Logstash as follows and running the container whose logs are to be viewed by changing its default log driver to syslog.

#logstash.conf

input {
  tcp {
    port => 5000
  }
}

output {
  stdout {}
}

The below container's logs will reach the logstash and and can be viewed through stdout.

docker run --log-driver=syslog --log-opt syslog-address=tcp://<logstash-system-ip>:5000 <image>


来源:https://stackoverflow.com/questions/39362983/docker-container-cannot-send-log-to-docker-elk-stack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!