Syslog 驱动程序无法与 docker compose 和 elk 堆栈一起使用
Syslog driver not working with docker compose and elk stack
我想将日志从一个容器 运行 my_service
发送到另一个 运行 带有 syslog
驱动程序的 ELK
堆栈(所以我需要logstash-input-syslog
插件已安装)。
我正在通过以下 Dockerfile-elk
调整 this elk image(并将其标记为 elk-custom
)
(使用端口 514
因为 this seems to be the default port)
FROM sebp/elk
WORKDIR /opt/logstash/bin
RUN ./logstash-plugin install logstash-input-syslog
EXPOSE 514
运行 我的服务通过 docker-compose
大致如下:
elk-custom:
# image: elk-custom
build:
context: .
dockerfile: Dockerfile-elk
ports:
- 5601:5601
- 9200:9200
- 5044:5044
- 514:514
my_service:
image: some_image_from_my_local_registry
depends_on:
- elk-custom
logging:
driver: syslog
options:
syslog-address: "tcp://elk-custom:514"
但是:
ERROR: for b4cd17dc1142_namespace_my_service_1 Cannot start service
my_service: failed to initialize logging driver: dial tcp: lookup
elk-custom on 10.14.1.31:53: server misbehaving
ERROR: for api Cannot start service my_service: failed to initialize
logging driver: dial tcp: lookup elk-custom on 10.14.1.31:53: server
misbehaving ERROR: Encountered errors while bringing up the project.
有什么建议吗?
更新:显然似乎没有任何东西在端口 514
上侦听,因为从容器内部,命令 netstat -a
在此端口上没有显示任何内容。 ...不知道为什么...
您需要使用 tcp://127.0.0.1:514
而不是 tcp://elk-custom:514
。原因是这个地址正在被 docker
使用,而不是被容器使用。这就是无法访问 elk-custom
的原因。
所以只有当您映射端口(您已经完成)并且 elk-service 首先启动(您已经完成)并且 IP 可以从 docker 主机访问时,这才会起作用,因为你会使用 tcp://127.0.0.1:514
我想将日志从一个容器 运行 my_service
发送到另一个 运行 带有 syslog
驱动程序的 ELK
堆栈(所以我需要logstash-input-syslog
插件已安装)。
我正在通过以下 Dockerfile-elk
elk-custom
)
(使用端口 514
因为 this seems to be the default port)
FROM sebp/elk
WORKDIR /opt/logstash/bin
RUN ./logstash-plugin install logstash-input-syslog
EXPOSE 514
运行 我的服务通过 docker-compose
大致如下:
elk-custom:
# image: elk-custom
build:
context: .
dockerfile: Dockerfile-elk
ports:
- 5601:5601
- 9200:9200
- 5044:5044
- 514:514
my_service:
image: some_image_from_my_local_registry
depends_on:
- elk-custom
logging:
driver: syslog
options:
syslog-address: "tcp://elk-custom:514"
但是:
ERROR: for b4cd17dc1142_namespace_my_service_1 Cannot start service my_service: failed to initialize logging driver: dial tcp: lookup elk-custom on 10.14.1.31:53: server misbehaving
ERROR: for api Cannot start service my_service: failed to initialize logging driver: dial tcp: lookup elk-custom on 10.14.1.31:53: server misbehaving ERROR: Encountered errors while bringing up the project.
有什么建议吗?
更新:显然似乎没有任何东西在端口 514
上侦听,因为从容器内部,命令 netstat -a
在此端口上没有显示任何内容。 ...不知道为什么...
您需要使用 tcp://127.0.0.1:514
而不是 tcp://elk-custom:514
。原因是这个地址正在被 docker
使用,而不是被容器使用。这就是无法访问 elk-custom
的原因。
所以只有当您映射端口(您已经完成)并且 elk-service 首先启动(您已经完成)并且 IP 可以从 docker 主机访问时,这才会起作用,因为你会使用 tcp://127.0.0.1:514