fluentd 聚合器未从转发器获取日志,配置是否正确?

fluentd aggregator not getting logs from forwarder, is the config correct?

我目前正在尝试设置 fluentd 的转发器和聚合器实例系统。 我的转发器配置是 ->

<source>
   @type tail
  format json
  path /app/node-apps/something-fe/logs/itt-logs.log
  tag td.pm2.access
</source>

## File output
## match tag=local.** and write to file
<match td.pm2.*>
  @type file
  path /opt/td-agent/forward/log/fluentd.log
</match>

## Forwarding
## match tag=system.** and forward to another td-agent server
<match td.pm2.*>
  @type forward
  host <hostname>.bc

这样做我可以看到转发器正在转发位置输出日志文件:/opt/td-agent/forward/log/fluentd.log 到目前为止一切都好!!! 但是当我尝试通过上面的匹配转发语法将它导入聚合器时,我在聚合器机器中没有得到任何东西。 请在这里找到我正在使用的 fluentd 聚合器配置 -->

<source>
  @type forward
      port 24224
</source>

<match td.pm2.*>
  type copy
    <store>
    @type file
    path /opt/td-agent/log/forward.log
  </store>
  <store>
    type elasticsearch
    host <aggreatorhost>.bc
    port 9200
    logstash_format true
    flush_interval 10s
  </store>
</match>

我正在尝试使用商店复制那里的日志,并将它们转发到 elasticsearch。 完全忘记弹性搜索,似乎甚至日志也没有从转发器填充到聚合器。 难道我做错了什么?聚合器日志说它正在侦听端口 24224 上的所有地址。

在您的转发器上,您有两个相同的匹配模式,并且只执行第一个匹配(配置是 运行 从上到下)。日志正在写入文件系统 (/opt/td-agent/forward/log/fluentd.log),但未转发到聚合器。

您实际上已经在聚合器上使用了正确的复制语法,您应该将其复制到您的转发器中,并将 elasticsearch 替换为聚合器的@forward 配置

<match td.pm2.*>
  type copy
    <store>
    @type file
    path /opt/td-agent/log/forward.log
  </store>
  <store>
    @type forward
    host <hostname>.bc
  </store>
</match>

进一步阅读:http://docs.fluentd.org/articles/out_copy

我认为有一个错字: type copy 之前必须有一个“@”符号。至少,根据我的经验,我可以说我的 td-agent 不允许我在没有“@”符号的情况下重新启动,所以我认为这是正确的,尽管不是 100% 确定。

@type copy

在上面代码的第二行。