transac-redline

0.2.3 • Public • Published

transac-redline

Build Status Dependency Status Coverage Status

NPM

transac-redline is a centralized logging system aimed at helping monitoring business applications.

It's a very pragmatic and simple system made of a restful HTTP server based on node.js and mongodb, a HTML single page application written with angularjs and clients (node.js, ruby, python, perl, ...).

Ruby, python, perl clients are not yet available, node's one is the NPM package called 'client-transac-redline'.

The node version is quite new, but the a previous version in ruby was in use for many years in very constraints production environments.

If you have to monitor results of many processes / batches (made in different languages) and you want to identify quickly their states, and in case of failure see why they failed, this tool is for you.

It's neither Nagios nor syslog, it's more business oriented, rather than system, it's a complementary tool for applications support teams.

Usage

npm install transac-redline

Setup params.js like this:

module.exports = {
  http:{
    port: 3002,
  },
  transac: {
    host: 'localhost',
    port: 27017,
    database: 'transacs',
  },
};

Write an express server to mount transac-redline on it:

var transac = require('transac-redline')
  , express = require('express')
  , connect = require('connect')
  , http = require('http')
  , app = express()
  , params = require('./params')
  , httpServer = http.createServer(app);
 
transac.start(params.transac, function(err, transacApp){
  httpServer.listen(params.http.port, function() {
    console.log("HTTP server listening on port: " + params.http.port);
 
    app.use(express.bodyParser());
    app.use(connect.logger('short'));
    app.use('/', transacApp);
  });
});
 

That's all your server is up. Point your brower on "http://localhost:3002/transacs/index.html" an transac again and again ... To initate transacs you need to use one the clients available (see NPM 'client-transac-redline').

All the code above is packaged in the 'server' directory of the distribution.

Concepts

A transac of course, is not a transaction, it's a set of messages associated with a name and a date.

A transac is uniquely defined by:

  • name: Name of the transac
  • valueDate: default to today, but can reference usually a past date. Useful when the processing date of a process is different from the reference date of elements processed.

A transac can be locked: it means system will refuse to execute a new transac with same couple (name, valueDate).

A transac is made of events: ('time', 'type', 'label', 'message'). type belongs to ['info', 'warning', 'error'].

A client can start, commit and abort a transac. All those actions only change transac's state which can be within ['ok', 'warning', 'error'].

A transac can imbricate other transacs on one level: a script is launched many times a day, to avoid to pollute our journal with the same transac's name, we can define just one transac made of all the transacs generated by the script. To do that just start your transac with nested option at true.

API

Server is made of 4 restful requests:

  • POST /transacs to register a transac

    • name: transac's name
    • valueDate: default to today
    • nested: will create a multi-transac, all new post with same valueDate and name will be nested in the same transacname: transac's name
    • valueDate: default to today
    • nested: default false, will create a multi-transac, all new post with same valueDate and name will be nested in the same transac
    • locked: default false, all new post with same valueDate and name will be rejected by client API
    • server: optional, client's server name
    • user: optional, client's user name
    • processId: optional, client's process ID
  • PUT /transacs/:id/events to add an event to transac.id

    • type: ['info', 'warning', 'error', 'commit', 'abort']
    • label
    • message
  • GET /transacs: return JSON list of transacs

  • mode: ['value || 'processing'] to select a query between valueDate and processingTime

  • startDate, endDate: dates range for query

  • GET /transacs/🆔 return JSON definition of a transac (could be a simple or multi transac);

TODO

  • add other clients (python, ruby, perl, ...)
  • send emails on abort or error
  • integrate with Nagios

Package Sidebar

Install

npm i transac-redline

Weekly Downloads

3

Version

0.2.3

License

MIT

Last publish

Collaborators

  • ebasley