首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在Fluentd中扩展JSON?

如何在Fluentd中扩展JSON?
EN

Stack Overflow用户
提问于 2020-09-28 23:32:59
回答 1查看 448关注 0票数 1

有没有办法在fluentd中过滤出嵌套的JSON字符串到单独的字段中?

当前JSON:

代码语言:javascript
运行
复制
 { 
   Value1: "something",
   Value2: "something",
   Message:{
             Value3: "Something",
             Value3: "Something"
          }
 }

我想要的(或类似的东西):

代码语言:javascript
运行
复制
 { 
   Value1: "something",
   Value2: "something",
   Message.Value3: "Something",
   Message.Value3: "Something"
          
 }

JSON不必像上面的示例那样被展平,但我确实希望当这些值到达elasticsearch时,它们位于各自独立的字段(列)中。在其他方面,我希望将单个长消息字符串拆分为其中包含的多个字段。

EN

Stack Overflow用户

回答已采纳

发布于 2020-09-29 03:54:07

试试这个:

代码语言:javascript
运行
复制
<source>
...
</source>

<filter myapp**>
  @type parser
  key_name Message

  format multi_format
  <pattern>
    format json # try parsing json in the first place
  </pattern>
  <pattern>
    format none # leave as is if this is not json (plaintext)
  </pattern>

  reserve_data true # keep the original Message field in case anything go wrong
</filter>

<match myapp**>
...
</match>

多格式解析器:https://github.com/repeatedly/fluent-plugin-multi-format-parser

票数 2
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64105238

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档