[英]How to match a pattern of “a=b c=d” with changing order in grok (logstash)?
我正在使用Logstash来匹配Fortinet分析器日志,问题是没有字段顺序的模式太多。
例如,一种消息类型是:
service=DNS hostname="abnet" profile="Dns" action=blocked reqtype=direct url="/" sentbyte=0 rcvdbyte=0 direction=N/A msg="URL belongs to a denied category in policy" method=domain cat=61 catdesc="Phishing" crscore=60 crlevel=high
...另一个是:
msg="File is infected." action=blocked service=HTTP sessionid=33137 direction=incoming filename="favicon.ico" quarskip=No-skip virus="MSWord/Agent.DD60!tr" dtype="Virus" ref="http://www.fortinet.com/ve?vn=MSWord%2FAgent.DD60%21tr" virusid=6920465 profile="AV"
如您所见,它们都有msg
, action
, service
和profile
但是顺序不同。
无论如何,有没有建立一个模式来匹配类似的东西:
(.*?)=%{DATA:\1?}\s
...同时为字段指定第一个匹配项的名称?
使用kv {}过滤器可以将其全部拆分,而不关心顺序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.