Giter Club home page Giter Club logo

fullstack-nanodegree-logs-analysis's Introduction

Logs Analysis

Prepare the software and data

  1. Download and install a virtual machine here
  2. Download the data here
  3. To load the data, cd into the vagrant directory and use the command psql -d news -f newsdata.sql

What report does the tool show?

  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?

Create views for project

Run the following commands to create views before run the script

  1. articles_views view contains article title and view
drop view article_views;
create view article_views as
    select articles.author, articles.title, paths_views.views
    from (
        select path, count(*) as views
        from log
        where status = '200 OK'
        group by path
    ) as paths_views
    right join articles
        on paths_views.path like ('/article/' || articles.slug);
  1. daily_error_date view to support "On which days did more than 1% of requests lead to errors?"
drop view daily_error_date;
create view daily_error_date as
    select daily_request.date, round(daily_error.error_request * 100.0 / daily_request.total_request, 2) as error_rate
    from (
        select time::date as date, count(*) as total_request
        from log
        group by date
    ) as daily_request
        join (
        select time::date as date, count(*) as error_request
        from log
        where status != '200 OK'
        group by date
    ) as daily_error
        on daily_request.date = daily_error.date;

How to run report?

execute the script

python report.py

Result

The most popular three articles of all time:
Candidate is jerk, alleges rival - 338647 views
Bears love berries, alleges bear - 253801 views
Bad things gone, say good people - 170098 views

The most popular article authors of all time:
Ursula La Multa - 507594 views
Rudolf von Treppenwitz - 423457 views
Anonymous Contributor - 170098 views
Markoff Chaney - 84557 views

which days did more than 1% of requests lead to errors:
2016-07-17 - 2.26% errors

fullstack-nanodegree-logs-analysis's People

Watchers

 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.