【问题标题】:Out of order logs between FluentD and FluentBitFluentD 和 FluentBit 之间的乱序日志
【发布时间】:2020-05-01 08:29:06
【问题描述】:

我目前正在使用 JournalD + JournalBeat + Logstash 作为日志堆栈,但我想切换到使用 JournalD + FluentD。

我尝试使用 https://github.com/fluent-plugin-systemd/fluent-plugin-systemd 作为 FluentD 的输入,但它会导致每秒约 1000 条日志行的低吞吐量,我需要至少支持 2000 条。

所以现在我正在尝试使用 JournalD + FluentBit + FluentD,在 FluentBit + FluentD 之间使用转发协议。使用此堆栈,我能够达到每秒 5000 条日志行的吞吐量,但会导致行乱序。实际上,乱序似乎是成块的。

这是我的 FluentBit 配置:

[SERVICE]
    # Flush
    # =====
    # Set an interval of seconds before to flush records to a destination
    Flush       5

    Daemon       Off
    HTTP_Server  On
    HTTP_Listen  0.0.0.0
    HTTP_Port    2020

[INPUT]
    Name            systemd
    Tag             host.*
    Systemd_Filter  _SYSTEMD_UNIT=docker.service
    Read_From_Tail  true
    Path            /var/log/journal

[OUTPUT]
    Name          forward
    Require_ack_response true
    Match         *
    Host          127.0.0.1
    Port          24224

这是我的 FluentD 配置:

    <source>
      @type forward
      @id input_forward
      tag docker.systemd
    </source>

    <match docker.systemd>
      @type copy
      <store>
        @type file
        @id out_file_docker
        path /file-logs/${$.CONTAINER_TAG}/%Y/%m/%d/${$.PRIORITY}
        append true
        <format>
          @type single_value 
          message_key MESSAGE
        </format>
        <buffer $.CONTAINER_TAG,$.PRIORITY,time>
          @type file
          path /var/log/fluentd/file-buffers/
          timekey 1d
          flush_mode interval
          flush_interval 10s
          flush_at_shutdown true
        </buffer>
      </store>
      <store>
        @type prometheus
        <metric>
          name fluentd_output_status_num_records_total
          type counter
          desc The total number of outgoing 
        </metric>
      </store>
    </match>

其他细节:

  • 我在 Docker 容器中运行 FluentD 和 FluentBit,具有 4gb 和 4096 个 CPU 份额
  • 两种服务的 CPU 使用率测量值均低于 20%

我尝试过的其他事情:

  • 将 FluentBit 中的 Mem_Buf_Limit 设置为 2MB,这可以修复乱序,但吞吐量仅为每秒 350 行。如果我使用更大的缓冲区,日志行会再次出现故障。
  • 将 FluentBit 输出设置为文件会导致日志行按顺序排列,但我无法在不同文件中分发日志。
  • 在 FluentBit 中使用较大的 Flush 间隔会导致较大的块乱序
  • 在 FluentD 中尝试 flush_thread_count 没有任何影响

我应该尝试任何其他设置/协议的想法吗? 有没有其他方法可以集成 Journal 和 FluentD?

----- 编辑----

使用 DEBUG 查看 FluentBit 日志,我明白了:

[2020/01/14 17:00:30] [trace] [upstream] destroy connection #52 to 127.0.0.1:24224
[2020/01/14 17:00:30] [trace] [upstream] destroy connection #100 to 127.0.0.1:24224

所以看起来正向输出正在使用多个线程。这是预期的吗?

【问题讨论】:

  • 使用 DEBUG 查看 FluentBit 日志,我看到:``` [2020/01/14 17:00:30] [trace] [upstream] destroy connection #52 to 127.0.0.1:24224 [ 2020/01/14 17:00:30] [trace] [upstream] 销毁连接 #100 到 127.0.0.1:24224 ``` 所以看起来正向输出正在使用多个线程。这是预期的吗?

标签: logging fluentd systemd-journald fluent-bit


【解决方案1】:

您可以在输入插件中添加Offset_Key,这样可以解决您在查询数据时遇到的问题,而且fluentbit不遵循命令。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-07-18
    • 2015-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多