我应该如何替换 Docker Swarm 中对 IP 的引用

How should I replace a reference to an IP in Docker Swarm

我正在尝试在 Docker Swarm 模式下安装 ELK。

然后,我需要告诉 filebeat 将日志发送到 logstash。

这是我的 filebeat 配置文件:

#=========================== Filebeat prospectors =============================
## Each - is a prospector. Most options can be set at the prospector level, so
## you can use different prospectors for various configurations.
## Below are the prospector specific configurations.
filebeat.prospectors:
- input_type: log
  enabled: true
  paths:
{% for log in in_filebeat_dict.filebeat.logs | default([]) %}
    - {{ log }}
{% endfor %}

#================================ Outputs =====================================
# Configure what output to use when sending the data collected by the beat.
output.logstash:
  hosts: ["{{ in_filebeat_dict.filebeat.output.logstash }}:{{ in_filebeat_dict.filebeat.output.port}}"]

但是in_filebeat_dict.filebeat.output.logstash是一个IP,在Swarm模式下,Swarm不会决定在哪里安装容器,所以我有点卡在这里...

有什么想法吗???

在 swarm 模式下,发现工作在 ne --name 参数上。因此,当您使用 --name logstash 部署 logstash 时,其他服务可以通过调用名称 logstash 来访问它。但请记住,它们需要在同一个网络中,而不是入口。如果您还没有创建一个新的覆盖网络并将所有服务分配给它。