我在将 API 日志从一台 Fluentd 服务器发送到另一台服务器,然后发送到 Elasticsearch 时遇到问题。什么时候 !尝试将日志直接从一台 Fluentd 服务器发送到 Elasticsearch,效果很好。现在,我怀疑连接可能有问题。但是,两个 Fluentd 服务器都设置为跨所有接口侦听 UDP 和 TCP 上的日志。我该如何解决这个问题?
Fluentd 服务器 1 配置
<source>
@type tail
@id input_log
<parse>
@type json
</parse>
path /home/ubuntu/OT-attendance/access.log
tag api.log
read_from_head true
</source>
<match api.log>
@type forward
@id output_system_forward
<server>
host 18.212.132.77
port 24225
</server>
</match>
Fluentd Server 2 配置
<match api.log>
@type elasticsearch
host localhost
port 9200
index_name fluentd.${tag}
</match>
这里有一些建议可以解决您的问题。
如果可能,删除其中一个 fluidd,并将日志直接发送到 Elasticsearch。额外的环将导致更多的延迟和问题。
Directly sending data from Fluentd server to Elasticsearch working fine
。每当有多个箍时,您应该一一测试。在您的数据流中,架构如下所示。
Fluentd => Fluentd => Elasticsearch
为了调试,您可以从输出中删除 Elasticsearch 添加 stdout 并在终端中检查结果。如果看不到任何结果,则说明 Fluentd 之间存在问题。这样,您就可以解决您的问题。