2016-08-17 47 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', '= ', '="" ' ] 
} 

谢谢。