Git Product home page Git Product logo

homeassignment's Introduction

HomeAssignment

Please implement as part of home assignment integration tests for small util log formatter. It is command-line util, which transforms logs from access log format to collection log format and also splits logs into defined size blocks.

Executing example of the util:

python log_formatter.py format-logs --input_logs <log file or folder> --output_folder <folder to save results> --api_key <provide key[any string]> --block_size <size of logs in single output file>

Example - the input file/folder contains 1000 lines of access logs. We define block_size = 350. The result of util execution will be 2 files with block size 350 and 1 file with block size 300.

Example of collection log format:

    {
        "common": {
            "attributes": {
                "plugin_attributes": {
                    "input_logs": "input_logs",
                    "block_size": 2000
                },
                "plugin": {
                    "type": "dataset-formatter",
                    "version": "0.2.0"
                },
                "api_key": "some_api_key|DatasetFormatter"
            }
        },
        "logs": [
            {
                "attributes": {},
                "message": "45.138.4.22 - - [20/Dec/2020:06:05:35 +0100] \"POST /index.php?option=com_contact&view=contact&id=1 HTTP/1.1\" 200 188 \"-\" \"Mozilla/5.0(Linux;Android10;MAR-LX1BBuild/HUAWEIMAR-L21B;wv)AppleWebKit/537.36(KHTML,likeGecko)Version/4.0Chrome/85.0.4183.81MobileSafari/537.36EdgW/1.0\" \"-\"",
                "timestamp": 1645075807256
            },
            {
                "attributes": {},
                "message": "45.153.227.31 - - [20/Dec/2020:12:33:49 +0100] \"GET /index.php?option=com_contact&view=contact&id=1 HTTP/1.1\" 200 9873 \"-\" \"Mozilla/5.0(WindowsNT6.1;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/83.0.4103.116Safari/537.36\" \"-\"",
                "timestamp": 1645075807257
            }
        ]
    }

Block size is defined as the size of array logs. In the current example, the block size is 2. As for the previous example, each file will contain the current JSON (collection format) with according logs array size

message contains the original access log from input file.

timestamp is insertion time of specific log to logs array.

common.attributes.plugin_attributes.block_size is meta-info on block size.

common.attributes.api_key is argument which provided to util with suffix |DatasetFormatter

####input_log folder contains 2 access log files.

homeassignment's People

Contributors

alexm-neosec 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.