logstash mutate 过滤器总是将散列和数组字符串化
logstash mutate filter always stringifies hash and array
我有一个 json 日志文件,我将其作为此配置的输入
input {
file { filename }
codec { json_lines }
}
每一行都是一个深度嵌套JSON。
在过滤器中,
当我说
mutate { add_field => { "new_field_name" => "%{old_field_name}"}
- 如果 old_field 是嵌套的 hash/array,它会被转换为字符串,然后添加。无论如何我可以保留类型而不是将其字符串化吗?
您可以考虑使用 ruby 过滤器来复制数组:
filter {
ruby { code => "event['newhash'] = event['myhash']" }
}
我认为没有更清洁的解决方案。
除此之外,您真的使用 json_lines 编解码器来输入文件吗?来自 logstash 文档:
Do not use this codec if your source input is line-oriented JSON, for
example, redis or file inputs. Rather, use the json codec.
我有一个 json 日志文件,我将其作为此配置的输入
input {
file { filename }
codec { json_lines }
}
每一行都是一个深度嵌套JSON。
在过滤器中,
当我说
mutate { add_field => { "new_field_name" => "%{old_field_name}"}
- 如果 old_field 是嵌套的 hash/array,它会被转换为字符串,然后添加。无论如何我可以保留类型而不是将其字符串化吗?
您可以考虑使用 ruby 过滤器来复制数组:
filter {
ruby { code => "event['newhash'] = event['myhash']" }
}
我认为没有更清洁的解决方案。
除此之外,您真的使用 json_lines 编解码器来输入文件吗?来自 logstash 文档:
Do not use this codec if your source input is line-oriented JSON, for example, redis or file inputs. Rather, use the json codec.