Grok_正则表达式

Grok的正则表达式,虽然不是太全,但是已经可以满足日志分析的需求。

转载请说明出处,谢谢。

如果有错误请指出,谢谢。

#----------------------------------------------------------------------------------------------------------------------------------------------------------------------

#DavisDing

#2017-09-10

#第一版

名字例子正则表达式
IPV4null(?<![0-9])(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))(?![0-9])
IPV6 null((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?
IPnull(?:%{IPV6:UNWANTED}|%{IPV4:UNWANTED})
域名null(?:[a-zA-Z0-9]{1,62}(\.[a-zA-Z0-9]{1,62})\.(cn|com|net))
时间匹配12/Jan/2017:15:39:12 +0800(?:\[[01][0-9]/\w{3}/\d{2,4}:\d{1,2}:\d{1,2}:\d{1,2} \+\d{4}\])
URLnull(?:(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?)
null
hostnull(?:[a-zA-Z0-9]{1,62}(\.[a-zA-Z0-9]{1,62})\.(cn|com|net))
nullnull(?:.*)
nullnull(?:\d+)
collect timenull(?:[012][0-9]/\w{3}/\d{2,4}:\d{1,2}:\d{1,2}:\d{1,2})
MZ55null(?:\+\d{4})
http_methodhttp方法(?:\w{3,8})
urlnull(?:/[\\A-Za-z0-9$.+!*'(){},~:;=@#% \[\]_<>^\-&?]*)+
protocolnull(?:\w{2,8}/.*)
statusnull(?:[1-5][01][0-9])
client request size客户请求大小(?:\d+)
collect timenull(?:[012][0-9]/\w{3}/\d{2,4}:\d{1,2}:\d{1,2}:\d{1,2})
nullnull(?:\w+)
nullnull(?:.+/[1-9]{1,2}\.[0-9]{1,2})
dst portnull(?:[1-9]\d{1,5})
USERNAMEnull[a-zA-Z0-9._-]+
INTnull(?:[+-]?(?:[0-9]+))
BASE10NUM十进制,数字和小数(?<![0-9.+-])(?>[+-]?(?:(?:[0-9]+(?:\.[0-9]+)?)|(?:\.[0-9]+)))
QuotedString有引号字符串(?>(?<!\\)(?>"(?>\\.|[^\\"]+)+"|""|(?>'(?>\\.|[^\\']+)+')|''|(?>`(?>\\.|[^\\`]+)+`)|``))
HostNamenull\b(?:[0-9A-Za-z][0-9A-Za-z-]{0,62})(?:\.(?:[0-9A-Za-z][0-9A-Za-z-]{0,62}))*(\.?|\b)
MONTH英月份\b(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\b
MONTHDAY一月的天数(?:(?:0[1-9])|(?:[12][0-9])|(?:3[01])|[1-9])
DAY英 天(?:Mon(?:day)?|Tue(?:sday)?|Wed(?:nesday)?|Thu(?:rsday)?|Fri(?:day)?|Sat(?:urday)?|Sun(?:day)?)
YEAR(?>\d\d){1,2})
HOUR时间,小时(?:2[0123]|[01]?[0-9])
MINUTE时间,分(?:[0-5][0-9])
SECOND时间,秒(?:(?:[0-5]?[0-9]|60)(?:[:.,][0-9]+)?)
Timenull(?!<[0-9])%{HOUR:UNWANTED}:%{MINUTE:UNWANTED}(?::%{SECOND:UNWANTED})(?![0-9])
commonmacmac(?:(?:[A-Fa-f0-9]{2}:){5}[A-Fa-f0-9]{2})
windowsmacmac(?:(?:[A-Fa-f0-9]{2}-){5}[A-Fa-f0-9]{2})
ciscomacmac(?:(?:[A-Fa-f0-9]{4}\.){2}[A-Fa-f0-9]{4})
word任意单词\b\w+\b
data数据 , 任意单词.*
uuidnull[A-Fa-f0-9]{8}-(?:[A-Fa-f0-9]{4}-){3}[A-Fa-f0-9]{12}
time2016-09-08 11:13:19,864,毫秒%{YEAR:UNWANTED}-%{MONTHNUM:UNWANTED}-%{MONTHDAY:UNWANTED}[T ]%{HOUR:UNWANTED}:?%{MINUTE:UNWANTED}(?::?%{SECOND:UNWANTED}),?%{NUMBER:UNWANTED}
timeyyyy-mm-dd  21:24:30%{YEAR:UNWANTED}-%{MONTHNUM:UNWANTED}-%{MONTHDAY:UNWANTED}[T ]%{HOUR:UNWANTED}:?%{MINUTE:UNWANTED}(?::?%{SECOND:UNWANTED})
number数字引用base10num(?:%{BASE10NUM:UNWANTED})
date usnull%{MONTHNUM:UNWANTED}[/-]%{MONTHDAY:UNWANTED}[/-]%{YEAR:UNWANTED}
date eunull%{MONTHDAY:UNWANTED}[./-]%{MONTHNUM:UNWANTED}[./-]%{YEAR:UNWANTED}
timemm/dd/yy 16:17:57 CST%{DATE:UNWANTED} %{TIME:UNWANTED} %{TZ:UNWANTED}
tzcst(?:[PMCE][SD]T|UTC)
datenull%{DATE_US:UNWANTED}|%{DATE_EU:UNWANTED}
time时分秒,16:17:57(?!<[0-9])%{HOUR:UNWANTED}:%{MINUTE:UNWANTED}(?::%{SECOND:UNWANTED})(?![0-9])
OTHER DATEAug 21 23:58:56 10.195.157.179%{MONTH:UNWANTED} %{MONTHDAY:UNWANTED} %{TIME:UNWANTED}
no have不要,不引用?:
UNWANTED未知,可做keyUNWANTED

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值