Git Product home page Git Product logo

logs-analysis's Introduction

NewsDB Reportýng Tool

NDBRT ýs a reporting tool that prints out reports (in plain text) based on the data in the news database. This reporting tool is a Python program using the psycopg2 module to connect to the database.

Installation

make sure psycopg2 is installed before runing the program $ pip3 install psycopg2

Usage

in order for this tool to run correctly, a few views must be cretaed in the database first. use the following lines to setup these views after connecting to the database in postgresql

$psql $\c news

pathHits: create view pathHits as select path, count(*) as hits from log where status='200 OK' and path !='/' group by path order by hits desc;

ArticleViews: create view ArticleViews as select a.title, p.hits from articles as a join pathHits as p on p.path like ('%' || a.slug);

ArticleAuthor: create view ArticleAuthor as select a.title,u.name as Author from articles as a join authors as u on a.author=u.id;

ArticleAuthorViews: create view ArticleAuthorViews as select aa.title, aa.Author, av.hits from ArticleAuthor aa join ArticleViews av on aa.title=av.title;

topAuthors: create view topAuthors as select author, sum(hits) as views from ArticleAuthorViews group by author order by views desc;

requests: create view requests as select date_trunc('day', time)::timestamp::date date, count(*) as requests from log group by 1 order by 1;

errors: create view errors as select date_trunc('day', time)::timestamp::date date, count(*) as errors from log where status like (4 || '%') group by 1 order by 1;

errorPercentage: create view errorPercentage as select r.date, e.errors::decimal/r.requests::decimal*100 percentage from requests r join errors e on r.date=e.date;

License

MIT

logs-analysis's People

Contributors

ahmedehaddad avatar

Watchers

James Cloos 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.