系统相关
首页 > 系统相关> > grok debugger 正则解析nginx日志

grok debugger 正则解析nginx日志

作者:互联网

 

 

 

地址:https://grokdebug.herokuapp.com/

1.捞一段nginx的日志

这个是我的nginx日志格式:

'$remote_addr [$time_local] "$request" '

'$request_body $status $body_bytes_sent "$http_referer" "$http_user_agent" '

'$request_time $upstream_response_time';

对应的日志:

172.16.16.132 [22/Jul/2019:08:31:03 -0400] "GET / HTTP/1.1" - 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36" 0.000 -

 

输入日志后开始写正则

gork正则说明:https://anbc.gitbooks.io/elk-handbook/content/81grokzheng_ze_guo_lv_qi_pei_zhi.html

一定要对应,否则解析不出来

 

对应的,下面是我的ng日志的正则。 

%{IPORHOST:clientip} \[%{HTTPDATE:time}\] \"%{WORD:verb} %{URIPATHPARAM:request} HTTP/%{NUMBER:httpversion}\" \- %{NUMBER:http_status_code} %{NUMBER:bytes} \"(?<http_referer>\S+)\" \"(?<http_user_agent>(\S+\s+)*\S+)\".* %{BASE16FLOAT:request_time}

 

 

标签:grok,debugger,request,NUMBER,nginx,正则,time,日志
来源: https://www.cnblogs.com/lc226/p/11228215.html