日志格式修改为:
http {
log_format main '$remote_addr|[$time_local]|$hostname|$http_referer'
'|$status|$body_bytes_sent|'
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
}
收集后logstash中grok:
filter {
if [type] == "acc-messages-log" {
grok {
match => {"message" => "%{IP:clientip}\|\[%{HTTPDATE:time}\]\|%{IPORHOST:host}\|%{DATA:url}\|%{DATA:code}\|(?:%{NUMBER:bytes}|-)\|%{DATA:agent}$"}
}
}
}
效果: