Coder Social home page Coder Social logo

log_analysis's Introduction

Log Analysis

Project Overview

The database contains newspaper articles, as well as the web server log for the site. The log has a database row for each time a reader loaded a web page. Using that information, your code will answer questions about the site's user activity.

The program you write in this project will run from the command line. It won't take any input from the user. Instead, it will connect to that database, use SQL queries to analyze the log data, and print out the answers to some questions.

Steps to setup the project

Installing dependencies

These files configure the virtual machine and install all the tools needed to run this project.

  • Download the database setup: data
  • Unzip the same to get the newsdata.sql file.
  • Put the newsdata.sql file into the vagrant directory. This will automatically be available inside the virtual machine.
  • Download this project in the vagrant directory

In VM:

  • Navigate to the directory that has the vagrant file.
  • vagrant up to build the VM. (Required only during the first run)
  • vagrant ssh to connect.
  • cd /vagrant/log_analysis
  • psql -d news -f newsdata.sql to load the data.
  • python log_analysis.py

Views created to make query easier

CREATE VIEW requests AS
SELECT time::date AS day, count(*)
            FROM log
            GROUP BY time::date
            ORDER BY time::date;

create view errors as
SELECT time::date AS day, count(*)
                FROM log
                WHERE status != '200 OK'
                GROUP BY time::date
                ORDER BY time::date;

CREATE VIEW err_rate AS
SELECT requests.day,
        errors.count::float / requests.count::float * 100
        AS percentage
    FROM requests, errors
    WHERE requests.day = errors.day;

log_analysis's People

Contributors

vidhyaranganathan avatar

Watchers

 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.