Git Product home page Git Product logo

loganalysis_startercode's Introduction

Log Analysis db

The log analysis db is an internal reporting tool, to analyze a newspaper website and give a statistics about kind of articles the site's readers like, using information from the website database.

This tool will connect automatically to a fixed database called news, reading data mainly from 2 views (views_log, errors_log) then print in plain text the following statistics: 1- The 3 most reading articles 2- The most popular article authors 3- The days did more than 1% of website requests lead to errors

The Views creation syntax as follows: 1- Firstly for more details about the current used database, please see the How To run this tool/ the database section at the end of file.

2- Connect to the database from the database console by using \c followed by the database name, for ex., \c news, or from the shell prompt by using the command psql news.

3- Run the following two queries to create the needed Views by copy/ paste each one inside the database console then press Enter:

  create view views_log as
    select articles.id as article_l, articles.author as author_l
          , log.path as path_l, log.ip as ip_l, log.method as method_l
          , log.status as status_l, log.time as time_l, log.id as id_l
    from log join articles
    on log.path like '%' || articles.slug || '%'
  where log.method like 'GET%' and log.status like '2%';

  create view errors_log as
    select articles.id as article_l, articles.author as author_l
          , log.path as path_l, log.ip as ip_l, log.method as method_l
          , log.status as status_l, log.time as time_l, log.id as id_l
    from log left join articles
    on log.path like '%' || articles.slug || '%'
  where log.method like 'GET%'
          and (log.status like '4%' or log.status like '5%');

How To run this tool: 1- Its a python program, needs the python standard libraries to be installed on the pc, try this site https://www.python.prg/

2- The database connection to the news db is required, its a postgresql database, created under a Linux VM, for more details: https://youtu.be/djnqoEO2rLc

2- Finally the program can be run from the shell like (terminal on Mac or Linux) using the command python3 loganalysisdb.py, from git bash on Windows using python loganalysisdb.py, or just double clicked on the file.

loganalysis_startercode's People

Contributors

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