繁体   English   中英

Logstash grok 模式用字符串 Exception 捕获第一行

[英]Logstash grok pattern to catch the first line with the string Exception

这是一个示例日志:

2022-01-07 11:05:01,185 [http-nio-8080-exec-526] WARN  de.web.Main| = - Error while execute Request
javax.servlet.ServletException: com.cg.blart.web.HttpInvocationException: Invalid tenant session
    at com.cg.blume.web.DispatchingServlet.doGet(DispatchingServlet.java:169)
    at de.jinx.lee.web.AutoDBUpgradeDispatchingServlet.lambda$doGet$0(AutoDBUpgradeDispatchingServlet.java:200)
    at de.jinx.lee.web.AutoDBUpgradeDispatchingServlet.addMDCKey(AutoDBUpgradeDispatchingServlet.java:297)
Caused by: com.cg.blume.web.HttpInvocationException: Invalid tenant session
    at com.cg.blume.web.procedure.HttpSessionManager.get(HttpSessionManager.java:190)
    at de.jinx.lee.web.session.leeHttpSessionManager.get(leeHttpSessionManager.java:76)
    ... 41 more

这是目前的模式: ^.*?Exception: +%{DATA:exception}$

我得到的 output 很接近,但没有雪茄: "com.cg.blart.web.HttpInvocationException: Invalid tenant session" 对于我的生活,我无法让它与整条线相匹配。 你能给我指路吗? The desired output is: javax.servlet.ServletException: com.cg.blart.web.HttpInvocationException: Invalid tenant session

这是测试工具的链接: https://grokdebug.herokuapp.com/

解决方案是这种模式:

(?<DATA:mps_exception>.*?(Exception:).*)

这里解释: https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html#_custom_patterns

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM