2016-08-17 37 views
0

我與Logstash KV過濾面臨的問題處理空字段:如何Logstash

下面是示例事件:

2016-08-15T12:43:04.478Z 103.240.35.216 <190>date=2016-08-15 time=18:13:16 timezone="IST" device_name="CR25iNG" device_id=C2222-123 log_id=010302602002 log_type="Firewall" log_component="Appliance Access" log_subtype="Denied" status="Deny" priority=Information duration=0 fw_rule_id=0 user_name="" user_gp="" iap=0 ips_policy_id=0 appfilter_policy_id=0 application="" application_risk=0 application_technology="" application_category="" in_interface="PortA" out_interface="" src_mac=44:d9:e7:ba:5b:6c src_ip=172.16.16.19 src_country_code= dst_ip=255.255.255.255 dst_country_code= protocol="UDP" src_port=45541 dst_port=10001 sent_pkts=0 recv_pkts=0 sent_bytes=0 recv_bytes=0 tran_src_ip= tran_src_port=0 tran_dst_ip= tran_dst_port=0 srczonetype="" srczone="" dstzonetype="" dstzone="" dir_disp="" connid="" vconnid="" 

下面是KV濾波器輸出:

"@version" => "1", 
"@timestamp" => "2016-08-16T13:48:30.602Z", 
"type" => "cyberoam.input", 
"host" => "ip-172-31-6-249", 
"time" => "18:13:16", 
"timezone" => "IST", 
"status" => "Deny", 
"priority" => "Information", 
"duration" => "0", 
"iap" => "0", 
"application" => "", 
"application_risk" => "0", 
"application_technology" => "", 
"application_category" => "", 
"dst_country_code" => "protocol=UDP", 
"recv_pkts" => "0", 
"tran_src_ip" => "tran_src_port=0", 
"tran_dst_ip" => "tran_dst_port=0", 
"srczonetype" => "", 
"srczone" => "", 
"dstzonetype" => "", 
"dstzone" => "", 
"dir_disp" => "", 
"syslog_severity_code" => 5, 
"syslog_facility_code" => 1, 
"syslog_facility" => "user-level", 
"syslog_severity" => "notice", 
"date" => "2016-08-15", 

問題:

"dst_country_code" => "protocol=UDP", 
"tran_src_ip" => "tran_src_port=0", 
"tran_dst_ip" => "tran_dst_port=0", 

以上是由於空的鍵「dst_country_code」,「tran_src_ip」和「tran_dst_ip」。

我被建議使用mutate gsub將缺省值添加到空字段,用= \ w替換爲=「」。

但是這從來沒有奏效。

請大家幫忙。

+0

你可以顯示你製作的'mutate/gsub'過濾器嗎? – Val

+0

[空白值的Logstash kv過濾器問題]的可能重複(http://stackoverflow.com/questions/39389577/logstash-kv-filter-issue-with-blank-values) – baudsp

回答

2

我從Logstash社區得到了迴應,並且有效。

mutate { 
gsub => [ 'message', '= ', '="" ' ] 
} 

謝謝。