Nginx Log Analyser

Write a simple tool to analyze logs from the command line.

Start building, submit solution and get feedback from the community.
2Submit Solution
5 upvotes10 upvotes

The goal of this project is to help you practice some basic shell scripting skills. You will write a simple tool to analyze logs from the command line.

Requirements

Download the sample nginx access log file from here. The log file contains the following fields:

  • IP address

  • Date and time

  • Request method and path

  • Response status code

  • Response size

  • Referrer

  • User agent

You are required to create a shell script that reads the log file and provides the following information:

  1. Top 5 IP addresses with the most requests

  2. Top 5 most requested paths

  3. Top 5 response status codes

  4. Top 5 user agents

Here is an example of what the output should look like:

text
Top 5 IP addresses with the most requests:45.76.135.253 - 1000 requests142.93.143.8 - 600 requests178.128.94.113 - 50 requests43.224.43.187 - 30 requests178.128.94.113 - 20 requestsTop 5 most requested paths:/api/v1/users - 1000 requests/api/v1/products - 600 requests/api/v1/orders - 50 requests/api/v1/payments - 30 requests/api/v1/reviews - 20 requestsTop 5 response status codes:200 - 1000 requests404 - 600 requests500 - 50 requests401 - 30 requests304 - 20 requests

There are multiple ways to solve this challenge. Do some research on awk, sort, uniq, head, grep, and sed commands. Stretch goal is to come up with multiple solutions for the above problem. For example, instead of using awk, you can use grep and sed to filter and count the requests.

Join the Community

cdn.artica.top is the 6th most starred project on GitHub and is visited by hundreds of thousands of developers every month.

Rank 6th out of 28M!

336K

GitHub Stars

Star us on GitHub
Help us reach #1

+90kevery month

+2.1M

Registered Users

Register yourself
Commit to your growth

+2kevery month

40K

Discord Members

Join on Discord
Join the community

RoadmapsBest PracticesGuidesVideosFAQsYouTube

cdn.artica.topby@kamrify

Community created roadmaps, best practices, projects, articles, resources and journeys to help you choose your path and grow in your career.

© cdn.artica.top·Terms·Privacy·

ThewNewStack

The top DevOps resource for Kubernetes, cloud-native computing, and large-scale development and deployment.