logstash filter 處理json數據按原始數據字段數據存儲

以下是實例

原始數據:

{"countnum":2,"checktime":"2017-05-23 16:59:32"}

{"countnum":2,"checktime":"2017-05-23 16:59:32"}  



1、無涉及字段類型轉換   logstash filter  配置如下參數即可

if [type] == "onlinecount" {

       json{

    source => "message"

     }

  }



2、涉及字段類型轉換

logstash filter  


if [type] == "onlinecount" {

mutate{

split=>["message",","]

add_field => {

"coutnum" => "%{[message][0]}"

}

add_field => {

"checktime" => "%{[message][1]}"

}

remove_field => ["message"]

}

json{

source => "coutnum"

source => "checktime"

#convert => { "coutnum" => "integer" }

target => "coutnum"

target => "checktime"

}

}




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章