问题
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.
- If the java app running standalone without docker, it works fine.
- 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