Fluentbit 创建 TCP 连接

Fluentbit creates TCP connections

Fluentbit 创建到自身的 TCP 连接?

这些有什么用?

fluent.conf 文件:

[SERVICE]
    Flush       5
    Daemon      Off
    Log_Level   debug
    
[INPUT]
    Name    tail
    Tag     format.logging
    path    C:\Logs\*main.log
    DB      C:\Logs\main_logs.db

[OUTPUT]
    Name    stdout
    Match   *

这似乎归结为一个实现细节,它在 Linux 上使用 unix 套接字作为其事件循环,但在 Windows 上它选择使用本地主机连接。

评论来自 https://github.com/fluent/fluent-bit/blob/37aa680d32384c1179f02ee08a5bef4cd278513e/lib/monkey/mk_core/deps/libevent/include/event2/util.h#L380

/** Create two new sockets that are connected to each other.
    On Unix, this simply calls socketpair().  On Windows, it uses the
    loopback network interface on 127.0.0.1, and only
    AF_INET,SOCK_STREAM are supported.
    (This may fail on some Windows hosts where firewall software has cleverly
    decided to keep 127.0.0.1 from talking to itself.)
    Parameters and return values are as for socketpair()
*/

实际实现在这里:https://github.com/fluent/fluent-bit/blob/37aa680d32384c1179f02ee08a5bef4cd278513e/lib/monkey/mk_core/deps/libevent/evutil.c#L207

它与查看 netstat 输出时的模式匹配:

netstat -anop tcp | findstr <fluentbit pid>
  TCP    127.0.0.1:54645        127.0.0.1:54646        ESTABLISHED     12012  \
  TCP    127.0.0.1:54646        127.0.0.1:54645        ESTABLISHED     12012  ´` Pair

  TCP    127.0.0.1:54647        127.0.0.1:54648        ESTABLISHED     12012  \
  TCP    127.0.0.1:54648        127.0.0.1:54647        ESTABLISHED     12012  ´` Pair