Giter Club home page Giter Club logo

internal-reporting-tool's Introduction

Project: Log Analysis

A SQL Query Project, replicating a given mock-up live database using Postgresql and Python to create a reporting tool that produces a plain text file containing answers to 3 specific questions.

Requirements

Get it started.

Setting up VM configuration

Downloading a copy

  • Fork the repository. (You may fork or not totally up to you)

  • Once you have your own repository. You may click Clone or download, then use HTTPs section and copy the clone URL. (Put it inside your vagrant subdirectory)

Start the virtual machine

  • Once inside the vagrant subdirectory, run the command: vagrant up

  • Upon installation, run this command to log you inside the VM. vagrant ssh

Set up the database

  • Unzip newsdata.zip. now you should have a folder called "newsdata" which contains the following:

    • newsdata.sql - creates the tables and alterations neccesary for the news database.
    • database_setup.sql - setup the news database and creates views neccesary.
  • Once logged on in vagrant, to load the data and create the database, run this command inside the "newsdata" folder: psql -f database_setup.sql

  • For more information on the views required for the queries. See Views Below.

Running the report tool

  • Run this command: python3 report.py This should result in a creation of a file called "reportfile.text"

Questions

  1. What are the most popular three articles of all time?
  2. Who are the most popular article authors of all time?
  3. On which days did more than 1% of requests lead to errors?

Views

  • viewcount - counts the views per article (Used in Questions 1 & 2)
create view viewcount as
select ar.author as id, ar.title, l.view_count
from articles as ar left join (
    select path, count(path) as view_count
    from log
    where status like '%200%'
group by log.path)
as l
on ar.slug = substring(l.path from 10);
  • log_errors - tallies the logs and errors per each day. (Used in Question 3)
create view log_errors as
select date_trunc('day', time) as date, count(*) as logs, sum(case when status='404 NOT FOUND' then 1 else 0 end) as errors
from log
group by date;
  • percentage - calculates the percentage of error per day. (Used in Question 3)
create view percentage as
select date, round((errors/logs::numeric)*100,2) as error_percentage
from log_errors
group by date, errors, logs
order by error_percentage desc;

Nanodegree Course courtesy of Udacity.

internal-reporting-tool's People

Contributors

russeladrianlopez 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.