日志文件中的一行如下,
"10 Sep 2014 07:16:33 , INFO , REST , xxx-xxxx-xxx1-yyyy , classname , [ <<MyClass>> Start -> mymessage #######]"
我想用逗号作为分隔符拆分整行。
IE)
Date = 10 Sep 2014 07:16:33
level = INFO
Layer = REST
Txid = xxx-xxxx-xxx1-yyyy
classname = classname
message = [ <<MyClass>> Start -> mymessage #######]
我应该如何编写我的grok过滤器?
答案 0 :(得分:0)
添加图案
COMMA_DELIMITER %{SPACE},%{SPACE}
过滤器如下:
filter {
grok {
patterns_dir => "/root/mypatterns"
match => ["message", "%{DATESTAMP:LOG_DATE}%{COMMA_DELIMITER}%{LOGLEVEL:LEVEL}%{COMMA_DELIMITER}%{WORD:LAYER}%{COMMA_DELIMITER}%{UUID:txid}%{COMMA_DELIMITER}%{WORD:classname}%{COMMA_DELIMITER}%{GREEDYDATA:filtered_message}"]
}
date {
match => ["LOG_DATE", "dd MMM yyyy HH:mm:ss"]
}
}