You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置Fluent Bit从JSON的log属性中提取日志内容?

如何配置Fluent Bit提取嵌套在"log"属性中的日志内容

你的日志消息格式如下,需要从外层的log属性里提取内部的结构化日志字段:

{
    "log": "{\"timestamp\":\"2022-09-30T20:01:50.002\",\"level\":\"INFO\",\"thread\":\"main\",\"logger\":\"com.app.Main\",\"message\":\"Started Main in 5.456 seconds (JVM running for 6.12)\",\"context\":\"default\"}\n",
    "stream": "stdout",
    "time": "2022-09-30T20:01:50.002746176Z"
}

配置方案

  1. 定义嵌套JSON解析器
    在Fluent Bit的配置文件中添加专门解析log字段的解析器:
[PARSER]
    Name        nested_log_parser
    Format      json
    # 指定解析log字段中的JSON内容
    Decode_Field_As    json    log
  1. 添加Parser过滤器
    通过过滤器将解析器应用到日志流,完成嵌套JSON的提取:
[FILTER]
    Name        parser
    Match       *
    Parser      nested_log_parser
    # 保留原始log字段(不想保留就设为False)
    Preserve_Key    True
    # 保留原有stream、time等其他字段
    Reserve_Data    True

配置生效后,Fluent Bit会把log字段里的JSON字符串解析成timestamp、level、message等结构化字段,这些字段会和原有的stream、time字段共存于处理后的日志中。

内容的提问来源于stack exchange,提问作者Christian Schneider

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 22:01:17