logstash grok切分nginx日志

日志类型

map $http_x_forwarded_for $clientRealIp {
"" $remote_addr;
~^(?P<firstAddr>[0-9\.]+),?.*$ $firstAddr;
}

log_format  proxy_main  '$clientRealIp "$http_x_forwarded_for" $remote_addr - $remote_user [$time_local] "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" $request_time $upstream_response_time '
                        '$proxy_host $upstream_addr';

日志格式

120.92.12.137 "1.1.1.1, 2.2.2.2" 120.92.12.137 - - [10/Jul/2019:03:38:16 +0000] "GET /api HTTP/1.1" 406 - "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.75 Safari/537.3 skyeye-scanner" 0.105 0.104 127.0.0.1:8080 127.0.0.1:8080

 

切分格式

(?<clientRealIp>%{IP}|-) \"(?<http_x_forwarded_for>([0-9., ]+|-))\"\s(?<remote_addr>%{IP}|-)\s-\s%{NOTSPACE:remote_user} \[%{HTTPDATE:time_local}\] \"%{WORD:method} (?<request_uri>(.*)) HTTP/%{NUMBER:http_version}\" %{NUMBER:status} (?:%{NUMBER:body_bytes}|-) \"%{NOTSPACE:http_referer}\" %{QS:agent} %{NUMBER:request_time} %{NUMBER:upstream_response_time} (?:%{HOSTPORT:proxy_host}|-) (?:%{HOSTPORT:upstream_addr}|-)

转载于:https://www.cnblogs.com/lfdblog/p/11170735.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值