如何在logstash中获取字段值?

时间:2016-04-29 02:41:31

标签: logstash

来自我的输出,如下所示,

  

"消息" =>"< .......",   
" @版本" => " 1&#34 ;,   
" @时间戳" => " 2016-04-29T02:33:34.586Z&#34 ;,   
"时间戳" => " 4月29日10:30:37",   
" syslog_severity_code" => 5,   
" syslog_facility_code" => 1,   
" SYSLOG_FACILITY" => "用户级&#34 ;,   
" syslog_severity" => "通知"

我尝试获取字段值

filter
 {
    mutate {
    add_field => {"newfield"=> "timestamp"}
 }

但仍无法获得newfield的时间戳值 它会得到

"newfield" => "newfield",

是否有人遇到同样的问题或找到解决方案? 欢迎任何帮助来解决这个问题。

1 个答案:

答案 0 :(得分:0)

这很简单,就这样做:

filter
 {
   mutate {
    add_field => ["newfield"=> "%{timestamp}"]
 }

你可以得到:

   "message" => "test it \b\b",
  "@version" => "1",
"@timestamp" => "2016-04-28T09:16:56.934Z",
      "host" => "bag",
 "timestamp" => "Apr 29 10:30:37",
 "new_field" => "Apr 29 10:30:37"