【发布时间】:2018-07-11 04:30:37
【问题描述】:
我在尝试找出以下消息类型的 grok 表达式时遇到了很多麻烦(来自 Sophos UTM)
2018 年 4 月 28 日 16:57:49 utm-vap-xx.domain.local: 04:28-17:02:05 s-utm-01 httpproxy[52816]: id="0001" severity="info" sys="SecureWeb" sub="http" name="http access" action="pass" method="POST" srcip="10.11.110.5" dstip="216.163.176.36" user="" group="" ad_domain= "" statuscode="200" cached="0" profile="REF_DefaultHTTPProfile (默认 Web 过滤器配置文件)" filteraction="REF_DefaultHTTPCFFAction (默认内容过滤器操作)" size="15" request="0xdae2cc00" url="http:/ /iprep3.t.ctmail.com/SpamResolverNG/SpamResolverNG.dll?DoNewRequest"referer=""error=""authtime="0" dnstime="905" cattime="143" avscantime="2275" fullreqtime="238344" device="0" auth="0" ua="Mozilla/4.0 (compatible; Win32; Commtouch Http Client (curl))" exceptions="" category="178" credit="neutral" categoryname="Internet Services" country ="美国" content-type="text/html" 沙箱="-"
当我想跳过字段或值对包含空字符串时,就会出现问题。例如在 Logstash 添加类似
()?(srcip={%"IP:SourceIP"})
正在引起问题,而这些在在线 grok builder 中确实有效
目标是得到类似的东西
Sub
SourceIP
Destination IP
Protocol etc
我还打算在 Logstash 中使用我已经与其他来源合作的地理标签。
期待收到一些有价值的帮助。谢谢
【问题讨论】:
-
改用kv 过滤器。使用 grok 只是为了获取
httpproxy[52816]:之后的文本,然后在此使用 kv 过滤器。默认字段和值拆分应该可以工作,但您必须使用 trim_value 删除"