我想知道是否可以为同一个日志源解析几种类型的日志。 例如,我有两种不同类型的两种不同日志:
type = statistics:
date = 2012-07-16 time = 12:22:56 device_id = FE100C3909600504 log_id = 0200001075 type = statistics
pri = information session_id =“q6GJMuPu003642-q6GJMuPv003642”client_name =“[172.20.140.94]”
dst_ip =“172.20.140.92”from =“user@external.lab”to =“user5@external.lab”subject =“”mailer =“mta”
resolved =“OK”direction =“in”virus =“”disposition =“拒绝”classifier =“收件人验证”
message_length中= “188”
type = spam
date = 2012-07-16 time = 12:22:56 device_id = FE100C3909600504 log_id = 0300001075 type = spam pri = information session_id =“q6GJMuPu003642-q6GJMuPv003642”client_name =“[172.20.140.94]” dst_ip =“172.20.140.92”from =“user@external.lab”to =“user5@external.lab”subject =“”msg =“ ......用户不明“
在过滤器(logstash)中,如何为Fortimail中的日志为每种类型执行多个正则表达式?
答案 0 :(得分:0)
试试此过滤器
filter {
ruby {
code => "
event['type'] = event['message'].split('type=')[1].split(' ')[0]
"
}
if [type] == "statistics" {
grok {
// parsing statistics logs
}
}
if [type] == "spam" {
grok {
// parsing spam logs
}
}
}
首先,获取日志的type
,然后使用条件if
来解析不同类型的日志。
希望这可以帮到你。 :)