awk分析nginx请求时日志
- nginx日志格式最后加上请求时间 "$request_time"
- 如下:
log_format main ‘$remote_addr – $remote_user [$time_iso8601] “$request” ‘ ‘$status $body_bytes_sent “$http_referer” ‘ ‘”$http_user_agent” “$http_x_forwarded_for” ‘ ‘ “$upstream_addr” “$upstream_status” “$request_time” ‘;
- shell脚本如下
cat access.log| awk '{print $7,$(NF)}'| awk -F'"' '{print $1,$2}'|awk '($NF>1){print $0}'