Code Monkey home page Code Monkey logo

logwatcher's Introduction

LogWatcher

Simply put: LogWatcher is a Log Watch Tool with Custom Filtering created using syslog-rfc5424-parser and websockets libraries of Python and served with Django

Event logs of multiple systems can be sent to a remote log server for central management. Usually logs are text files without structure. Most of the logs are about usual activities and irrelevant for a system administrator. Filtering the logs for relevant events based on the content is essential in a central log management software.

LogWatcher is a small prototype of this type of a customizable log management software. Logs coming from different hosts and facilities are filtered and watched by user. User is able to define custom rules for a log filter and incoming log source will be applied to these rules and matching log entries will be displayed in an online environment (immediately).

Each log filter object has its own set of rules to match a log entry based on:

  • IP of the host generating the log
  • Log severity (debug, info, notice, error, critical, etc)
  • Log facility (mail, kernel, daemon, ...)
  • Fields in log body (seperated by a predefine seperator)
  • Parts in log body to be found with given regular expressions

A filter match can be defined on equality, inequality, substring or regular expression based. Filter rules can be combined with logic operators conjunction and disjunction. In other words a filtering object ruleset will be a tree with rules at the leaves and logical operators in the nodes. User should be able to define a log resource (a file or a socket) and a ruleset in a filtering object. Then, as a new log matches the filter, it can be observed (read) by the user.

Internal Details

The filtering rules have a tree structure of user's choice since AND and OR operators can be used to combine match expressions. In order to edit this tree, user needs to address an arbitrary node or leaf. A path based addressing can be in form of list of binary branch choices as (0,1,1,0) denoting left, right, right, and left branch is traversed to get a subtree. The null tuple () denotes the root tree.

The match value is a tuple in the form (matchfield, operator, value, negated, caseinsens).

matchfield is one of WHOLE, IP, SEVERITY, FACILITY, FIELD:range:sep, RE:regexp:field. WHOLE matches the whole normalized syslog message. IP is ip number or hostname specified in the log. For SEVERITY and FACILITY comparison was made based on manual pages of syslog. The FIELD is followed by a range description, either a single number two numbers seperated by a dash. the last subfield is the separator symbol. For example FIELD:2-5:, will seperate log line with ,, compose a substring from field 2 (starting from 0) to 5 inclusive and match that string. RE:regexp:field passes syslog message on a regular expression substitute and subtitutes it with the given field. This way message body extracts the regular expression based group. The value is simply: re.sub(regexp, '\g<' + field + '>', message).

operator is one of EQ, LT, LE, GT, GE, or RE. RE is used for regular expression match assuming value is a regular expression. All the others are comparison operators. value is the other operand of the operator. First operand is the log component. If negated is True the calculated match value is reversed. If caseinsens is true all matches are case insensitive, values are converted to lowercase and than compared.

Installation and Usage

First clone the repository

git clone https://github.com/simsekhalit/LogWatcher/

Install requirements

cd LogWatcher/
pip3 install -r requirements.txt

Create database

./manage.py migrate

Create an admin account

./manage.py createsuperuser

Run django server

./manage.py runserver

Then start

watcher/logwatch_manager.py

After that you can login from browser and create LogWatch objects which will listen incoming logs from 5140 port.

For a demo, you can use watcher/tests/demo.txt.

Contribution

Feel free to open an issue if you find a bug ๐Ÿ˜Š.

logwatcher's People

Contributors

simsekhalit avatar ysyesilyurt avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

dave360-crypto

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.