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

Fluentd单个match块匹配多标签及tag分段取值问题

Fluentd 多tag匹配提取子段配置解决方案

错误原因

你使用${tag_prefix[1]}无法获取目标值是变量选择错误:

  • tag_prefix[N]的作用是返回tag前N段拼接的完整前缀,比如tag为app.one时,tag_prefix[1]返回app,tag_prefix[2]返回app.one,无法单独提取第二段内容。

正确配置方案

你需要使用tag_parts[N]变量,该变量会将tag按.分割为数组,索引从0开始计数,你的tag格式为app.xxx,所以tag_parts[1]正好对应你需要的one/two/three值。

如果你的自定义Test输出插件原生支持record_accessor语法,直接使用原配置的subsystemname ${tag_parts[1]}即可生效。

如果插件不支持直接注入tag变量,可以新增filter段提前预处理字段,配置示例如下:

<label @TESTLABEL>
  <!-- 新增filter预处理字段 -->
  <filter app.*>
    @type record_transformer
    enable_ruby true
    <record>
      subsystemname ${tag_parts[1]}
    </record>
  </filter>
  <match app.*>
    @type Test(confidential so adding test)
    subsystemname ${subsystemname}
    is_json true
  </match>
</label>

验证方法

你可以临时将输出插件替换为stdout,打印tag和字段值确认取值正确:

<match app.*>
  @type stdout
  <format>
    @type stdout
    output_tag true
  </format>
</match>

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.11 01:36:04