Nginx无法连接EFK栈中的fluentd



我正在设置一个由nginx, redis, mysql, myapp组成的应用程序堆栈。Nginx代理请求到myapp。我想从nginx发送日志到EFK堆栈,但是在启动nginx服务时发生错误:

Error response from daemon: dial tcp 127.0.0.1:24224: connect: connection refused

docker-compose。Yml for stack with myapp

version: "3.8"
services:

nginx:
image: nginx:alpine
deploy:
mode: replicated
replicas: 2
labels:
- traefik.enable=true
- traefik.http.routers.node1.rule=Host(`${NODE1}`)
- traefik.http.routers.node1.service=nginx
- traefik.http.routers.node2.rule=Host(`${NODE2}`)
- traefik.http.routers.node2.service=nginx
- traefik.http.routers.node3.rule=Host(`${NODE3}`)
- traefik.http.routers.node3.service=nginx
- traefik.http.services.nginx.loadbalancer.server.port=80
placement:
constraints:
- node.role == manager
logging:
driver: fluentd
options:
fluentd-address: localhost:24224
tag: nginx-
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
ports: 
- 80:80
depends_on: 
- myapp
networks:
- traefik-public
...

所有栈都在相同的交通公共网络中,如果你从任何容器中生成ping fluentd, fluentd响应

efk.yml部分

version: "3.7"
services:
fluentd:
image: registry.rebrainme.com/docker_users_repos/3912/dkr-30-voting/fluentd
deploy:
mode: global
volumes:
- /mnt/fluent.conf:/fluentd/etc/fluent.conf
ports:
- "24224:24224"
- "24224:24224/udp"
depends_on:
- elasticsearch
- kibana
networks:
- traefik-public
...

fluent.conf

<source>
@type forward
port 24224
bind localhost
</source>
<match *.**>
@type copy
<store>
@type elasticsearch
host elasticsearch
port 9200
logstash_format true
logstash_prefix fluentd
logstash_dateformat %Y%m%d
include_tag_key true
type_name access_log
tag_key @log_name
flush_interval 1s
</store>
<store>
@type stdout
</store>
</match>

我请求帮助

;

因为你正在使用2个撰写文件。docker-compose.ymlefk.yml在网络中不共享相同的值

<标题>

修复将两个文件合并成一个文件

修复(仍然有两个文件分开)

首先你应该创建一个网络。

docker network create traefik-public

然后用

更新两个组合文件
networks: 
default: 
external: 
name: traefik-public

这应该可以使它工作。

为了在efk堆栈和应用程序堆栈之间建立连接,有必要将fluentd端口绑定到主机端口

version: "3.7"
services:
fluentd:
image: my_fluentd_image:latest
deploy:
mode: global
configs:
- source: fluent-conf
target: /fluentd/etc/fluent.conf
ports:
- target: 24224
published: 24224
protocol: tcp
mode: host
depends_on:
- elasticsearch
- kibana
networks:
- traefik-public

相关内容

  • 没有找到相关文章

最新更新