简体   繁体   中英

Docker container cannot send log to docker ELK stack

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

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM