Giter Site home page Giter Site logo

20171128_logs-analysis-project's Introduction

20171128_Logs-Analysis-Project

Udacity Logs Analysis project This program shows the answer of questions below

Questions

  1. What are the most popular 3 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?

How to run

  1. Load the news data in the database.
psql -d news -f newsdata.sql
  1. Connect to the news database.
psql -d news
  1. Create views. check the "Create views" section below
  2. Disconnect from news database.
  3. Execute logs_analysis.py.

Create views

create view logview as
(select substring(path from 10) slug, ip, method, status, time, id from log);
create view authorview as
(select au.id, au.name, ar.slug from authors au, articles ar where au.id = ar.author);
create view PopularArticles as
(select a.slug, a.title, count(*) as view from articles a, logview lv
where a.slug = lv.slug group by a.slug, a.title order by view desc);
create view PopularAuthors as
(select av.name, sum(PA.view) as view
from authorview av, PopularArticles PA
where av.slug = PA.slug
group by av.name
order by view desc);
create view ErrorRate as
(select errorcount.date, cast(errorcount.count as real)/cast(totalcount.count as real) errorrate 
from (select time::timestamp::date as date, count(*) from log where status != '200 OK' group by date) as errorcount, 
(select time::timestamp::date as date, count(*) from log group by date) as totalcount 
where errorcount.date = totalcount.date and cast(errorcount.count as real)/cast(totalcount.count as real) > 0.01);

20171128_logs-analysis-project's People

Contributors

hajeong-noh 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.