Giter VIP home page Giter VIP logo

log-analysis's Introduction

LogAnalysis

LogAnalysis is an internal reporting tool that will use information from the database to discover what kind of articles the site's readers like.

Tech

LogAnalysis uses a number of tools to work properly:

  • Python - an interpreted, high-level, general-purpose programming language.
  • PostgreSql - free and open-source relational database management system (RDBMS)
  • Oracle VirtualBox -free and open-source hosted hypervisor for x86 virtualization.

LogAnalysis requires Vagrant to run the virtual machine and Git Bash to execute commands.

Design description

LogAnalysis reporting tool consists of three parts represent three Sql queries which execute Sequentially and every query answers a question. Every part is coded as following:

  • define Database connection variable.
  • define Database cursor.
  • using the cursor to execute the query.
  • fetching the query result.
  • define a (for) loop to print out the result.
  • close the database connection.

Before we start

All data is stored in PostgreSql database called (news). Before running the tool we must create two Views (most_articles , bad_req_days) to let our reporting tool runs.

from [Git Bash] enter vagrant file directory:

1- run the virtual machine:

$ vagrant up
$ vagrant ssh

2- enter the database:

$ psql -d news                           

3- create the views:

news=>create view most_articles as
select substr(path,10) article,count(path) as num from log where status = '200 OK' group by path order by num desc offset 1;

news=>create view bad_req_days as
select count(status) bad_req_sum , TO_CHAR(time,'Month DD,YYYY') as day from log where status ='404 NOT FOUND'
group by TO_CHAR(time,'Month DD,YYYY') order by count(status) desc;

4-exit from PostgreSql:

news=>Ctrl+d

Run

/LogAnalysis: contains reporting tool (LogAnalysis.py)

$ cd /vagrant/LogAnalysis
$ python LogAnalysis.py

log-analysis's People

Contributors

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