解析LogStash中两种格式的日志消息

Parsing two formats of log messages in LogStash

在一个日志文件中,有两种格式的日志消息。首先是这样:

Apr 22, 2017 2:00:14 AM org.activebpel.rt.util.AeLoggerFactory info
INFO:
======================================================
ActiveVOS 9.* version Full license.
Licensed for All application server(s), for 8 cpus,
License expiration date: Never.
======================================================

第二个:

Apr 22, 2017 2:00:14 AM org.activebpel.rt.AeException logWarning
WARNING: The product license does not include Socrates.

第一行是一样的,但在其他行,可以有(伪写):
loglevel: <msg>,或
loglevel:<newline><many of =><newline><multiple line msg><newline><many of =>

我有以下配置:
查询:

%{TIMESTAMP_MW_ERR:timestamp} %{DATA:logger} %{GREEDYDATA:info}%{SPACE}%{LOGLEVEL:level}:(%{SPACE}%{GREEDYDATA:msg}|%{SPACE}=+(%{GREEDYDATA:msg}%{SPACE})*=+)

Grok 模式:

AMPM (am|AM|pm|PM|Am|Pm)
TIMESTAMP_MW_ERR %{MONTH} %{MONTHDAY}, %{YEAR} %{HOUR}:%{MINUTE}:%{SECOND} %{AMPM}

多行过滤器:

%{LOGLEVEL}|%{GREEDYDATA}|=+

问题是所有消息总是用 %{SPACE}%{GREEDYDATA:msg} 标识,所以在第二种情况下 return <many of => 被标识为 msg,而从不使用 %{SPACE}=+(%{GREEDYDATA:msg}%{SPACE})*=+ ], 可能是因为第一个 msg 模式包含第二个。

如何解析 msg 的这两种模式?

我通过以下方式修复了它:
查询:

%{TIMESTAMP_MW_ERR:timestamp} %{DATA:logger} %{DATA:info}\s%{LOGLEVEL:level}:\s((=+\s%{GDS:msg}\s=+)|%{GDS:msg})

模式:

AMPM (am|AM|pm|PM|Am|Pm)
TIMESTAMP_MW_ERR %{MONTH} %{MONTHDAY}, %{YEAR} %{HOUR}:%{MINUTE}:%{SECOND} %{AMPM}
GDS (.|\s)*

多行模式:

%{LOGLEVEL}|%{GREEDYDATA}

日志已正确解析。