# Fluent Bit

**Fluent Bit** 是一款开源遥测代理，负责收集、处理并转发日志、指标、追踪与性能剖析数据，其设计目标是在从资源受限的嵌入式系统到大型云基础设施的各类环境中高效运行。<sup>[1](https://docs.fluentbit.io/manual/about/what-is-fluent-bit)</sup> 它是 CNCF 毕业项目，隶属于 [Fluentd](https://www.edgepedia.org/zh/fluentd) 旗下，除支持 Prometheus 集成外，还原生支持 [OpenTelemetry](https://www.edgepedia.org/zh/opentelemetry)（OTLP）的接收与投递，既可部署为单个节点上的边缘代理，也可部署为汇聚多个来源的中央聚合器。<sup>[1](https://docs.fluentbit.io/manual/about/what-is-fluent-bit)</sup>

| 关键事实 | 详情 |
|---|---|
| 定位 | 面向日志、指标、追踪与性能剖析的开源遥测代理；CNCF 毕业项目，隶属 Fluentd<sup>[1](https://docs.fluentbit.io/manual/about/what-is-fluent-bit)</sup> |
| 起源 | 2014 年由爱德华多·席尔瓦（Eduardo Silva）在 Treasure Data 创建，用于嵌入式 Linux 与网关上的轻量日志处理<sup>[1](https://docs.fluentbit.io/manual/about/what-is-fluent-bit)</sup> |
| 实现方式 | 以 C 语言编写，采用与 Fluentd 类似的可插拔架构<sup>[2](https://essay.utwente.nl/87845/1/Colmenar_Lamas_MA_EEMCS.pdf)</sup> |
| 插件模型 | 约 80 个内置插件编译进单一二进制文件，而 Fluentd 需另行安装 500 多个社区 gem<sup>[3](https://nxlog.co/news-and-blog/posts/fluent-bit-vs-fluentd)</sup> |
| 缓冲单元 | 记录被分组为约 2 MB 的数据块（Chunk），默认驻留内存<sup>[4](https://fluentbit.io/blog/2024/01/29/a-practical-guide-for-avoiding-data-loss-and-backpressure-problems-with-fluent-bit/)</sup> |
| 背压工具 | 内存缓冲区超出上限时，`mem_buf_limit` 会暂停对应输入；文件系统缓冲将数据块落盘备份，`storage.max_chunks_up` 默认允许 128 个数据块驻留内存<sup>[5](https://docs.fluentbit.io/manual/1.5/administration/backpressure)</sup><sup> • </sup><sup>[4](https://fluentbit.io/blog/2024/01/29/a-practical-guide-for-avoiding-data-loss-and-backpressure-problems-with-fluent-bit/)</sup> |
| 当前版本 | v5.1 为稳定系列；v5.1.5 于 2026 年 10 月 21 日发布<sup>[6](https://github.com/fluent/fluent-bit/releases)</sup> |
| 采用情况 | Docker 拉取量超过一百亿次；部署次数超过十亿次<sup>[4](https://fluentbit.io/blog/2024/01/29/a-practical-guide-for-avoiding-data-loss-and-backpressure-problems-with-fluent-bit/)</sup><sup> • </sup><sup>[7](https://fluentbit.io/how-it-works/)</sup> |

## 目的与范围

Fluent Bit 起初是一个日志处理器，此后扩展至处理指标与追踪数据。它从本地文件和网络设备读取数据，抓取 Prometheus 格式的指标，并将数据发送至 Splunk、Elasticsearch、OpenSearch、Kafka 等目的地。<sup>[7](https://fluentbit.io/how-it-works/)</sup> 其设计者将其定位为既有日志层的补充而非直接替代品：它以厂商中立的方式调整并优化现有日志处理，同时增加指标与追踪处理能力。<sup>[1](https://docs.fluentbit.io/manual/about/what-is-fluent-bit)</sup>

每一条流入的数据，无论是日志行、指标、追踪还是性能剖析，都被视为一个事件（Event）或记录（Record）。一个事件由时间戳、可选的键值元数据（v2.1.0 及以后版本）以及负载组成，在传输线上表示为二元数组，时间戳与元数据嵌套在第一个元素内。为提升性能，Fluent Bit 采用二进制格式 [MessagePack](https://www.edgepedia.org/zh/messagepack) 序列化事件。<sup>[8](https://docs.fluentbit.io/manual/concepts/key-concepts)</sup>

## 数据管道

Fluent Bit 的引擎让数据流经一系列阶段构成的管道，其中大多数阶段以插件形式实现：输入、过滤器与输出。<sup>[9](https://docs.fluentbit.io/manual/stream-processing/overview)</sup>

1. **输入插件**发出记录，引擎将其分组为数据块。
2. **过滤器**修改记录，例如追加或删除键、用元数据丰富记录（如 [Kubernetes](https://www.edgepedia.org/zh/kubernetes) 过滤器补充的 Pod 与命名空间信息），或丢弃满足条件的记录。
3. **处理器**直接挂载到单个输入或输出插件上，而非通过标签匹配，并与其所属插件在同一线程中运行，在启用多线程时可提升吞吐量。
4. **路由**使用标签（Tag）——分配给每个事件的内部字符串——与匹配（Match）规则比对，决定由哪个过滤器或输出接收该事件。<sup>[8](https://docs.fluentbit.io/manual/concepts/key-concepts)</sup>
5. **输出**在数据进入安全状态（内存或文件系统）后将其投递出去。<sup>[9](https://docs.fluentbit.io/manual/stream-processing/overview)</sup>

除标准管道外，Fluent Bit 还内置流式 SQL 引擎，允许在连续数据流仍处于处理器中时对其进行查询。<sup>[9](https://docs.fluentbit.io/manual/stream-processing/overview)</sup>

## 缓冲与背压

当数据摄入速度快于其刷写到目的地的速度时，便会出现背压。这种情况常由网络故障、延迟或无响应的第三方服务引起，后果包括内存占用过高、服务宕机与数据丢失；在持续压力下，内核可能因进程超出内存限制而将其终止（OOM）。<sup>[4](https://fluentbit.io/blog/2024/01/29/a-practical-guide-for-avoiding-data-loss-and-backpressure-problems-with-fluent-bit/)</sup>

**默认内存缓冲。** 默认情况下，输入插件创建的每个数据块都驻留内存。这是速度最快、系统开销最小的机制，但在背压下内存消耗会无界增长。<sup>[4](https://fluentbit.io/blog/2024/01/29/a-practical-guide-for-avoiding-data-loss-and-backpressure-problems-with-fluent-bit/)</sup>

**Mem_Buf_Limit。** 该输入插件选项默认禁用，用于限制插件可登记的缓冲数据量。在达到上限之前，引擎的行为是宽松的：文档示例中，若上限为 1 MB，插件可以先追加 700 KB，再追加 500 KB，尽管总量 1.2 MB 已超出上限。一旦超出上限，引擎便阻塞该插件的本地缓冲区并调用其暂停回调，停止摄入，直至缓冲数据投递完毕。视插件类型不同，这可能意味着丢弃流入数据（如 TCP 输入插件的情形），因此该上限是以数据安全换取内存占用可控与服务存活。<sup>[5](https://docs.fluentbit.io/manual/1.5/administration/backpressure)</sup>

**文件系统缓冲。** 根本的解决方案是内存与磁盘相结合。启用文件系统缓冲后，引擎将每个新数据块存入内存，并通过 `mmap(2)` 在磁盘上建立副本映射，使数据块既活跃于内存，又在磁盘上留有备份。引擎限制同时驻留内存的数据块数量，由 `storage.max_chunks_up` 控制，默认值为 128；其余数据块保留在文件系统上，处于非内存驻留状态，直至可以投递。这在性能与数据安全之间取得平衡。<sup>[4](https://fluentbit.io/blog/2024/01/29/a-practical-guide-for-avoiding-data-loss-and-backpressure-problems-with-fluent-bit/)</sup> 实践者指出一个限制条件：文件系统缓冲需要可用的磁盘 I/O，若其他组件已使 IOPS 饱和，则不宜再添加此机制。<sup>[10](https://github.com/aws/aws-for-fluent-bit/blob/mainline/troubleshooting/debugging.md)</sup>

**限流。** 当目的地对输入限流时，仅调整 Fluent Bit 客户端设置通常无法消除限流，因为代理必须以摄入速度发送日志，否则便会形成积压。建议的补救措施是扩容目的地，或横向扩展 Fluent Bit 实例，使每个实例承担更少的工作。<sup>[10](https://github.com/aws/aws-for-fluent-bit/blob/mainline/troubleshooting/debugging.md)</sup>

## 历史与项目状态

2014 年，Treasure Data 的 Fluentd 团队预见到嵌入式 Linux 与网关需要更轻量的日志处理器，爱德华多·席尔瓦为此创建了 Fluent Bit。该项目随后在普通 Linux 系统上获得关注；随着容器化的普及，云原生社区要求提供更多的来源、过滤器与目的地，Fluent Bit 遂成为云环境日志处理的首选方案。<sup>[1](https://docs.fluentbit.io/manual/about/what-is-fluent-bit)</sup> 2024 年 [Chronosphere](https://www.edgepedia.org/zh/chronosphere) 收购 Calyptia 后，Chronosphere 成为主要企业赞助方，爱德华多·席尔瓦带领一支 Chronosphere 工程师团队全职投入该项目。<sup>[4](https://fluentbit.io/blog/2024/01/29/a-practical-guide-for-avoiding-data-loss-and-backpressure-problems-with-fluent-bit/)</sup>

当前稳定系列为 v5.1，在主分支上维护；v5.0 分支处于维护模式，接收关键缺陷修复、安全更新及部分低风险回移植，直至 2026 年 11 月 30 日。更早的版本线已终止支持：v4.2 于 2026 年 7 月 30 日终止支持，v4.1 于 2026 年 2 月 28 日终止支持，v4.0 于 2025 年 12 月 23 日终止支持。<sup>[11](https://github.com/fluent/fluent-bit/blob/master/MAINTENANCE.md)</sup> 5.1 系列近期的维护版本集中于摄入韧性、元数据保留、多行处理以及输入输出插件的安全加固。<sup>[6](https://github.com/fluent/fluent-bit/releases)</sup>

## Fluent Bit 与 Fluentd

两个项目刻意保持互补关系。Fluent Bit 占据轻量代理的生态位：它以 C 语言编写，采用与 Fluentd 类似的可插拔架构，将约 80 个内置插件编译进单一二进制文件，而 Fluentd 依赖另行安装的 500 多个社区 gem。<sup>[2](https://essay.utwente.nl/87845/1/Colmenar_Lamas_MA_EEMCS.pdf)</sup><sup> • </sup><sup>[3](https://nxlog.co/news-and-blog/posts/fluent-bit-vs-fluentd)</sup> Fluent Bit 同样支持 Fluentd Forward 传输协议；当 Forward 输入收到事件时，它使用客户端已设置的标签，而非自行分配。<sup>[8](https://docs.fluentbit.io/manual/concepts/key-concepts)</sup>

## References

1. [What's Fluent Bit?, Fluent Bit Official Manual](https://docs.fluentbit.io/manual/about/what-is-fluent-bit)
2. [Colmenar Lamas, Implementation of Centralized Logging, University of Twente](https://essay.utwente.nl/87845/1/Colmenar_Lamas_MA_EEMCS.pdf)
3. [Fluent Bit vs Fluentd: How to choose the right tool for your log pipeline, NXLog Blog](https://nxlog.co/news-and-blog/posts/fluent-bit-vs-fluentd)
4. [A practical guide for avoiding data loss and backpressure problems with Fluent Bit, Fluent Bit Blog](https://fluentbit.io/blog/2024/01/29/a-practical-guide-for-avoiding-data-loss-and-backpressure-problems-with-fluent-bit/)
5. [Backpressure, Fluent Bit Official Manual 1.5](https://docs.fluentbit.io/manual/1.5/administration/backpressure)
6. [Releases, fluent/fluent-bit, GitHub](https://github.com/fluent/fluent-bit/releases)
7. [How It Works, fluentbit.io](https://fluentbit.io/how-it-works/)
8. [Key concepts, Fluent Bit Official Manual](https://docs.fluentbit.io/manual/concepts/key-concepts)
9. [Stream Processing Overview, Fluent Bit Official Manual](https://docs.fluentbit.io/manual/stream-processing/overview)
10. [Debugging guide, aws/aws-for-fluent-bit, GitHub](https://github.com/aws/aws-for-fluent-bit/blob/mainline/troubleshooting/debugging.md)
11. [Fluent Bit Maintenance Policy, fluent/fluent-bit, GitHub](https://github.com/fluent/fluent-bit/blob/master/MAINTENANCE.md)

---
*Initially written Oct 26, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 网络与安全 › Network monitoring and analysis tools

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/fluent-bit

English original: https://www.edgepedia.org/fluent-bit
