Logstash没有正确处理MySQL日志

正如您所看到的,消息不仅仅是消息,还包含date和时间戳。

有效的XHTML有效的XHTML

这是MySQL日志:/var/log/mysql/error.log

150630 9:01:29 [Warning] Access denied for user 'test1'@'localhost' (using password: YES) 150630 9:03:39 [Warning] Access denied for user 'test3'@'localhost' (using password: YES) 150630 9:07:48 [Warning] Access denied for user 'test5'@'localhost' (using password: YES) 150630 9:10:00 [Warning] Access denied for user 'test7'@'localhost' (using password: YES) 150630 9:12:21 [Warning] Access denied for user 'test9'@'localhost' (using password: YES) 

这是Logstash-shipperconfiguration:/etc/logstash/shipper/conf.d/20-filter.conf

 else if [type] == "mysql" { grok { patterns_dir => "/etc/logstash/patterns" match => [ "message", "%{MYSQLLOG}" ] overwrite => [ "message" ] } } 

这是模式:

 MYSQLLOG %{NUMBER:date} %{TIME:time} \[%{LOGLEVEL:loglevel}\] %{GREEDYDATA:message} 

我一直在努力解决这个问题,而且实际上我已经在一段时间内工作了,但是没有我的结束干预,它又停止了工作。 有关debugging的任何提示?

看起来datetime字段之间的日志条目中有一个额外的空间,所以您的grok不匹配,如_grokparsefailure标记的存在所certificate。

试试这个模式:

 %{NUMBER:date} %{TIME:time} \[%{LOGLEVEL:loglevel}] %{GREEDYDATA:message} 

我已经在Grok构造器中testing过了,它匹配了你提供的所有行。