在Logstash中我正在使用grok
将日志行解析为具有扁平结构的事件。
例如:
{
location_file_name: "ServiceDao.java"
location_line_number: 47
thread_name: "main-thread"
thread_number: "3"
}
我怎样才能将其解析为:
{
location : {
file: "ServiceDao"
line: 47
}
thread : {
name: "main-thread"
number: "3"
}
}
答案 0 :(得分:1)
浏览完您的数据后,您可以使用mutate
过滤器按照您的意愿重新组织字段:
filter {
grok {
...
}
mutate {
add_field => {
"[location][file]" => "%{location_file_name}"
"[location][line]" => "%{location_line_number}"
"[thread][name]" => "%{thread_name}"
"[thread][number]" => "%{thread_number}"
}
remove_field => ["location_file_name", "location_line_number", "thread_name", "thread_number"]
}
}