Code Monkey home page Code Monkey logo

log-analyzer's Introduction

Log Analyzer

Analyzes a server's log files to uncover most popular posts and most popular authors.

Motivation

This is a project from Udacity's Full Stack Nanodegree program. Its intent is to show how SQL can be used to analyze a website log.

Getting Started

Provided you'll find a Vagrant environment with all dependencies.

Prerequisites

To run Vagrant, you will need to install Vagrant and VirtualBox.

Installing

From within the project root:

  1. Start Vagrant environment
$ cd vagrant
$ vagrant up

It can take a little while for this to complete since it needs to download and install everything 2. SSH into Vagrant environment:

$ vagrant ssh
  1. Change to project directory
$ cd /vagrant
  1. Load data into the news database. A test log is included:
$ psql -d news -f newsdata.sql
  1. Create database views:
$ python3 create_db_views.py
  1. Run the analyzer:
$ python3 log_analyzer.py

If all works, you should get 3 tables like this:

----------------Popular Articles-----------------

 Candidate is jerk, alleges rival | 338647 views
-------------------------------------------------
 Bears love berries, alleges bear | 253801 views
-------------------------------------------------
 Bad things gone, say good people | 170098 views

Design

Data is retrieved from the database using 3 functions:

# Returns 3 most popular articles
get_three_popular_articles()

# Returns a list of all authors, in order of popularity (number of views)
get_popular_authors()

# Returns the percentage of errors (404 errors / total request) grouped by day
# min is the minimum error percentage to filter
get_error_data(min=0)

There is also a helper module called table_maker to handle formatting the data

Built With

Acknowledgments

Original virtual machine from Udacity

log-analyzer's People

Contributors

byanofsky avatar

Stargazers

Peter Lee avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.