Coder Social home page Coder Social logo

matrixloginstallation's Introduction

Matrix Log

Matrix Log has following projects

Docker containers

  • mongodb, Matrix Log Importer will import logs and Presenter will read
  • php-cli, for the Matrix Log Importer
  • nginx, for the Matrix Log Presenter
  • php-lumen, for the Matrix Log Presenter

Microservices

CLI application which can parse very large log files, log file will be splited in the smaller files for the reading purpose, batch size its 10000 lines, with this approach we can have much faster reading and in combination with yield we can not have some memory usage errors. When we start with import we will read the last entered line and the script will start from the next one.

Usage

$ php application.php app:import-logs {filePath}

Run Unit tests

$ php vendor/bin/phpunit tests/

Lumen application to read log data, for now it's only implemented counting feature by provided filter

Example Request: http://localhost/matrix?services=USER-SERVICE&statusCode=201&fromDateTime=17-08-2018 10:00:00 +0000&toDateTime=18-08-2018 10:32:00 +0000

Example Response:

{
    "counter":2
}

With this microservices we can easily scale import and data presentation.

Instalation

1. Clone All repositories

git clone https://github.com/denis019/matrixLogDocker.git .
git clone https://github.com/denis019/MatrixLogPresenter.git
git clone https://github.com/denis019/MatrixLogImporter.git

In the end we will have the following file structure

matrixLogDocker
MatrixLogImporter
MatrixLogPresenter

2. Start Docker images with docker-compose

docker-compose up --build -d

3. Install composer dependencies

docker exec -it matrix_php_cli bash
root@c7cc74533e5e:/var/www/matrix-log/MatrixLogImporter# composer install
docker exec -it matrix_php_lumen bash
root@c7cc74533e5e:/var/www/matrix-log/MatrixLogImporter# composer install
## Run Unit Tests
php vendor/bin/phpunit tests/
## Import example logs
php application.php app:import-logs /var/www/matrix-log/MatrixLogImporter/tests/log-pool/example-logs.log
docker exec -it matrix_php_lumen bash
root@ced986f2e3d7:/var/www/matrix-log/MatrixLogPresenter# composer install

Open http://localhost/matrix?services=USER-SERVICE&statusCode=201&fromDateTime=17-08-2018+10%3A00%3A00+%2B0000&toDateTime=18-08-2018+10%3A32%3A00+%2B0000

Notes

If you want to handle periodicaly log file add cron to hit the following script

php application.php app:import-logs /var/www/matrix-log/MatrixLogImporter/tests/log-pool/example-logs.log

TODO

  • handle better different environment for Matrix Log Importer
  • improve Repostiory abstraction for Matrix Log Importer
  • add config for Matrix Log Importer

matrixloginstallation's People

Contributors

denis019 avatar

Watchers

 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.