Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Logstash使用键将字符串分解为数组_Logstash - Fatal编程技术网

Logstash使用键将字符串分解为数组

Logstash使用键将字符串分解为数组,logstash,Logstash,这是我的管道输出: "attributes" => "Width:150,200;Height:200;Size:L" 我想要一个输出: "attributes" => [ "Width" => [ 150, 200 ], "Height" => 200, "Size" => "L" ] 我试着使用变异过滤器 mutate { split => ["attributes", ";

这是我的管道输出:

"attributes" => "Width:150,200;Height:200;Size:L"
我想要一个输出:

"attributes" => [
    "Width"  => [
        150,
        200
    ],
    "Height" => 200,
    "Size"   => "L"
]
我试着使用变异过滤器

mutate {
    split => ["attributes", ";"]
}
它以这种方式转换数据

"attributes" => [
    [0] "Width:150",
    [1] "Height:200"
    [2] "Size:L"
]
有没有办法通过logstash过滤器对其进行转换?

您可以使用过滤器:


您可以直接使用split

 filter {
      split {
            field => "attributes"
          }
      }
以下是文件:

只是一个小小的添加,如果我有“宽度:100150;高度…”,我能用逗号将偶数值分解为数组吗?你可以将它与你在讨论中使用的变体结合起来。我得到了一个新的字段名,有没有办法在“属性”中保留它?另外,如何用一个新的字段名(在拆分之前我不知道)来定位突变更新了我的答案,以便保存在“属性”中。你可以稍后在mutate中引用[attributes][Weight]。问题是我不知道会有多少属性(宽度、高度、大小,可能还有100多个),有没有办法在某种循环中重命名字段?拆分筛选器将事件拆分为多个事件
 filter {
      split {
            field => "attributes"
          }
      }