发送TCP数据包到Fluentd

时间:2019-06-25 02:28:47

标签: tcp splunk fluentd

在我的Mac OS中,我使用fluentd尝试读取tcp事件并将其写入本地目录。

下面是我创建的用于打开TCP端口并写入本地的td-agent.conf

  <!-- td-agent.conf-->
  <source>
    @type tcp
    @log_level "trace"
    tag "tcp.events"
    port 2201
    bind "0.0.0.0"
    delimiter "\\n"
    <parse>
      @type "regexp"
      expression "/^(?<field1>\\d+):(?<field2>\\w+)$/"
    </parse>
  </source>
  <match tcp.events>
    @type file
    path "/Users/logs/outputlog"
    <buffer time>
      path "/Users/logs/outputlog"
    </buffer>
  </match>

为了测试,我正在使用2201telnet之类的工具将tcp软件包发送到端口(netcat)。但是终端连接到端口后不会返回。它停留在那里,没有任何回应。

检查telnet / netcat的详细信息。没有运气。

我希望TCP能够连接并获取记录在fluentd日志中的数据。但是已建立与端口的连接,但数据未写入日志或tcp连接的控制未返回给终端。

1 个答案:

答案 0 :(得分:0)

将以下内容添加到您的conf文件中。

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

https://docs.fluentd.org/input/forward