2016-08-03 83 views
0

在Logstash中,我目前使用grok將日誌行解析爲具有扁平結構的事件。如何構建添加到logstash事件的字段?

例如:

{ 
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

所著的Grokking數據後,你可以重新組織你的領域,你認爲合適使用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"] 
    } 
} 
+0

有沒有這樣的運氣? – Val

相關問題