Code Monkey home page Code Monkey logo

news-log-analysis's Introduction

Log Analysis +

This project queries database logs and generates user logs as per defined criteria.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

Programming Language:

Python - Tested on ver. 3.5.2

Virtual Machine

Download and Install:

Virtual Box Vagrant

Download and unzip the configuration package VM Config prepared by Udacity. Inside the vagrant subdirectory, along with other starter project, clone this repository. On terminal, at the same subdirectory, run vagrant up, then vagrant ssh.

Download and unzip the data here to the vagrant subdirectory. Run psql -d news -f newsdata.sql. This will connect and setup the database server.

Create Views

This project require the following database views to be created before running the script:

CREATE VIEW top_paths (views, path, slug) AS SELECT count(path), path, substring(path from 10) AS slug FROM log WHERE
method = 'GET' AND  status = '200 OK' GROUP BY path HAVING path LIKE '/article/%' ORDER BY count(path) DESC;
CREATE VIEW articles_views (article, author_id, views) AS SELECT articles.title, articles.author, top_paths.views FROM articles JOIN top_paths ON articles.slug = top_paths.slug;
CREATE VIEW day_errors (date, error, no_error, error_percent) AS SELECT sub.day, error, good, (error/((error + good)/1.0)*100) AS rate FROM (SELECT DATE_TRUNC('day', time) AS day, count(status) AS error FROM log WHERE status = '404 NOT FOUND' GROUP BY day) sub JOIN ( SELECT DATE_TRUNC('day', time) AS day, count(status) AS good FROM log WHERE status = '200 OK' GROUP BY day) sub2 ON sub.day = sub2.day;

Running the Script

On terminal, run:

python report.py

Contributing

Please fork this forked repo, and make a PR.

Note

SQL file ignored in this repo

Acknowledgements

Udacity

news-log-analysis's People

Contributors

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