Docker容器无法将日志发送到Docker ELK堆栈 [英] Docker container cannot send log to docker ELK stack
问题描述
我部署了ELK堆栈和Spring Boot应用程序的另一个分离的Docker容器.
I deployed ELK stack and another separated docker container of spring boot app.
在Java应用程序中,我使用LogstashSocketAppender将日志发送到Logstash.
In the java app, I use the LogstashSocketAppender to send logs to logstash.
- 如果Java应用程序在没有docker的情况下独立运行,则可以正常运行.
- 但是当它作为docker容器运行时,logstash无法接收日志.
有人可以帮我弄清楚吗?
Can anyone help me figure out it?
logstash配置的一部分:
part of logstash configuration:
input {
udp {
port => 5000
type => syslog
codec => json
}
}
dcoker端口:
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
推荐答案
您可以通过如下配置Logstash并通过将其默认日志驱动程序更改为 syslog .
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 {}
}
以下容器的日志将到达日志记录中,并且可以通过 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>
这篇关于Docker容器无法将日志发送到Docker ELK堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!