如何解决我可以提高摄取管道 GROK 模式的性能吗?
背景:我想摄取apache错误日志,通过modsecurity进行了丰富。为此,我更改了 apache 模块的摄取管道。
modsecurity 日志不完全共享一个共同的模式。正因为如此,我想为这些提供两个 grok 模式。我使用了 grok 调试器来创建它们并且都可以工作。
问题是,它们似乎很慢:当我使用摄取管道模拟 API 测试它们时,我得到:"grok pattern matching was interrupted after [1000] ms"
。取决于我是否将匹配的 grok 模式作为 patterns
数组中的第一个或第二个元素。
要分解问题,请使用以下 grok 模式:
^\[%{APACHE_TIME:apache.error.timestamp}\] \[\:%{LOGLEVEL:log.level}\] \[pid %{NUMBER:process.pid:long}\] \[client %{IPORHOST:source.address}:%{POSINT:source.port}.*\[file "%{PATH:modsec.rule.path}.* \[id "%{NUMBER:modsec.rule.number}"\] \[msg "%{MODSECMSG:message}.*? \[hostname "%{IPORHOST:host.hostname}"\] \[uri "%{URIPATH:url.path}"\] \[unique_id "%{MODSECMSG:modsec.unique_id}"\],referer\: %{URI:http.request.referrer}$
需要很长时间才能注意到它与此日志条目不匹配:
[Tue May 11 12:30:02.209790 2021] [:error] [pid 29329] [client 127.0.0.1:59586] [client 127.0.0.1] ModSecurity: Warning. Matched phrase "etc/passwd" at ARGS:page. [file "/usr/share/modsecurity-crs/rules/REQUEST-930-APPLICATION-ATTACK-LFI.conf"] [line "99"] [id "930120"] [msg "OS File Access Attempt"] [data "Matched Data: etc/passwd found within ARGS:page: /etc/passwd"] [severity "CRITICAL"] [ver "OWASP_CRS/3.1.0"] [tag "application-multi"] [tag "language-multi"] [tag "platform-multi"] [tag "attack-lfi"] [tag "OWASP_CRS/WEB_ATTACK/FILE_INJECTION"] [tag "WASCTC/WASC-33"] [tag "OWASP_TOP_10/A4"] [tag "PCI/6.5.4"] [hostname "localhost"] [uri "/dvwa/vulnerabilities/fi/"] [unique_id "YJp4yhyfYYeU0eSqwUU4GwAAAAA"]
因此解析失败并出现上述错误,因为下一个确实与日志条目匹配的 grok 模式不再执行。
有什么方法可以优化我的模式或更改超时值?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。