baicai

白菜

一个勤奋的代码搬运工!

awk analysis commonly used commands for nginx running logs

title: "Common Awk Commands for Analyzing Nginx Access Logs"
date: 2021-06-05T10:16:16+08:00
draft: false
slug: "Awk-nginx-access_log"
tags: ["Shell Script","awk"]
categories: ["Using Software","Shell","Nginx"]
description: "Common Awk commands for analyzing Nginx access logs"


Common Awk Commands for Analyzing Nginx Access Logs

  1. Unique IP addresses
awk '{print $1}' access.log | sort -r |uniq -c | wc -l
  1. Count PV (Page Views)
awk '{print $6}' access.log | wc -l
  1. Find the most frequently accessed URLs
awk '{print $7}' access.log|sort | uniq -c |sort -n -k 1 -r|more
  1. Find the most frequently accessed IP addresses
awk '{print $1}' access.log|sort | uniq -c |sort -n -k 1 -r|more
  1. UV (Unique Visitors) statistics:
awk '{print $6}' access.log | sort -r |uniq -c |wc -l
  1. Hourly statistics
cat access.log |awk '{print $4}' | awk -F ':' '{print $1,$2}'|uniq -c | awk '{print $2" "$3" "$1}'
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.