码迷,mamicode.com
首页 > 其他好文 > 详细

Logstash解析Nginx访问日志

时间:2019-07-12 00:52:57      阅读:351      评论:0      收藏:0      [点我收藏+]

标签:cli   byte   udid   log   http   pst   tty   greedy   oca   

Nginx日志格式

    log_format  main  ‘$remote_addr - $remote_user [$time_local] "$request" ‘
                      ‘$status $body_bytes_sent "$http_referer" ‘
                      ‘"$http_user_agent" "$http_x_forwarded_for" ‘
                        ‘"$http_host" "$request_time" "$upstream_response_time" $http_device $http_appversion $upstream_addr ‘
                      ‘$http_openudid $http_code $http_networkType "$http_deviceModel" "$http_osVersion"‘;

解析格式为

%{IPORHOST:Client_IP} (%{NGUSER:ident}|-) (%{NGUSER:auth}|-) \[%{HTTPDATE:timestamp}\] "%{WORD:Http_Method} %{URIPATHPARAM:Http_Request} HTTP/%{NUMBER:Http_Version}" %{NUMBER:Http_Status_Code} (?:%{NUMBER:Http_Bytes}|-) (?:"(?:%{URI:Http_Referrer}|-)"|%{QS:Http_Referrer}) %{QS:User_Agent} "(%{QS:X_Forwarded_For}|-)" "(%{IPORHOST:Site}|-)" "(%{NUMBER:Request_Time}|-)" "(%{NUMBER:Upstream_Response_Time}|-)" (%{WORD:Device}|-) (%{USERNAME:App_Version}|-) (%{HOSTNAME:Upstream_Host}:%{POSINT:Upstram_Port}|-) (%{WORD:Openudid}|-) (%{WORD:Usercode}|-) (%{WORD:NetType}|-) "(%{GREEDYDATA:Device_Name}|-)" "(%{GREEDYDATA:System_Verion}|-)"

Logstash解析Nginx访问日志

标签:cli   byte   udid   log   http   pst   tty   greedy   oca   

原文地址:https://blog.51cto.com/fengwan/2419549

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!