我的kv过滤器的字段拆分类似于以下内容 -
field_split => ","
field_split基于逗号后跟空格。但我的一个值是json字符串。 logstash的输出似乎在遇到第一个逗号后忽略该值。 示例 - 日志的mdc字段类似于: abc = abcvalue request = {" key1":" value1"," key2":" value2"}
它将其解析为(输出定向到elasticsearch): " abc":" abcvalue" "请求":" {" key1":" value1""
如何获取请求字段如下? "请求":" {" key1":" value1"," key2":" value2"} "
答案 0 :(得分:1)
如果你真的有json,你可以匹配json并使用json过滤器解析它。
例如:
filter {
grok {
match => ["request=(?<request_json>{[^}]+})"] // match from { to first } and put in request_json
}
json {
source => "request_json"
target => "request"
remove_field => ["request_json"]
}
}