[英]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.