使用 dmesg 来查看一些硬件或驱动程序的信息或问题。

grok解析同时匹配多种格式

匿名 | 发布于2021年09月10日 | 阅读数:1650

格式1:[2021-08-31 11:10:29,765] [INFO] [com.xxxx.asdf.api.SpringBoot] The following profiles are active
格式2:
[2021-09-03 12:19:21,870][][main][INFO ][com.xxxx.asdf.api.SpringBoot][:][655][-]The following profiles are activ

该grok匹配第二条格式,怎么修改能同时匹配上面两条日志格式
^\[?%{TIMESTAMP_ISO8601:logTimestamp}\]?\[?\]?\[?(?<threadName>[0-9a-zA-Z\-\.\_]+)\]?\[?%{LOGLEVEL:loglevel}(\s)?\]?\[?%{JAVACLASS:javaClass}\]?\[:\]\[%{NUMBER:errorCode}\]\[-\]%{GREEDYDATA:string1}$
 
 
已邀请:

CobraDan

赞同来自:

1631270671(1).png

第一行的空格没有匹配上
^\[?%{TIMESTAMP_ISO8601:logTimestamp}\]?((\[?\]?)\[?(?<threadName>[0-9a-zA-Z\-\.\_]+)\]?|\s?)?\[?%{LOGLEVEL:loglevel}(\s)?\]?(\s)?\[?%{JAVACLASS:javaClass}\]?((\[:\]\[%{NUMBER:errorCode}\]\[-\])|\s)+%{GREEDYDATA:string1}$

要回复问题请先登录注册