node package manager


Provides utilities and abstractions over node.js client


Provides utilities and abstractions over node.js client

npm install riemann riemann-util

A small abstraction over riemann client that provides defaults, demands required fields and simplifies event dispatching.

var RiemannMonitor = require('riemann-util').RiemannMonitor;
var monitor = new RiemannMonitor({
role: 'ninja',
ttl: 60 * 60, // 1 hour in seconds 
var client = ... get a reference to riemann client somehow
metric: 5,
description: 'bar and foo',
service: 'bar'

contructs a riemann monitor.

config - see below

Binds a node.js riemann client to this monitor instance. Monitor will discard events if a client is not bound. If a client is not bound while the first event sent to the monitor, a single warning will be printed using console.warn()

client - an instance of a node.js riemann client

Sends an event to riemman. Defaults from config will be applied. Event data here will always override the config, except for tags, which will be concatenated to default tags.

event - a javascript object specifing one or more riemann event fields and their values

A convenience callback/event listener generator. Will return a function onError(err) {} that sends error events through this client.

All error events will be sent with default tags, argument tags, the service name and an error tag.

Their metric will be 1, their description will be an inspection of the error argument in onError and their ttl will be the default ttl or the error ttl specified in the config.

The error event time is in seconds and its state will be set to critical

serviceName - event service

tags - an array of additional tags

Override this to change the host label generation behavior.

Where it makes sense, configuration options can be overridden or augmented when sending an event.

// required, is sent with every event, included in default tags and might a be part of the host label.
role: 'worker',
// required, default ttl in SECONDS for each event
ttl: 10,
// optional, an array of tags that will be added to EACH event fired from this monitor
defaultTags: [],
// optional, completely override host label generation with a fixed host label. The default host label is [role]-[ip address]-[process id]
hostLabel: 'my-super-server-is-awesome',
// optional, if an event is missing a service use this. The default service is 'no_service_name'
service: 'foo-workers',
// optional, ttl used for error events generated through errorListener, if omitted ttl is used instead.
errorTTL: 20,

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Copyright (c) 2014 Yaniv Kessler. Licensed under the MIT license.