Godot is a streaming real-time event processor based on Riemann written in Node.js
Here is a simple example of a Reactor server that will send an email to [email protected]
if the Producer server for app.server
fails to send a heartbeat after 60 seconds.
var godot = require('../lib/godot');
//
// Reactor server which will email `[email protected]`
// whenever any service matching /.*\/health\/heartbeat/
// fails to check in after 60 seconds.
//
godot.createServer({
//
// Defaults to UDP
//
type: 'udp',
reactors: [
godot.reactor()
.where('service', '*/health/heartbeat')
.expire(1000 * 60)
.email({ to: '[email protected]' })
]
}).listen(1337);
//
// Producer client which sends events for the service
// `app.server/health/heartbeat` every 15 seconds.
//
godot.createClient({
//
// Defaults to UDP
//
type: 'udp',
producers: [
godot.producer({
host: 'app.server.com',
service: 'app.server/health/heartbeat',
ttl: 1000 * 15
})
]
}).connect(1337);
Similar to Riemann, events in godot
are simply JSON sent over UDP or TCP. Each event has these optional fields:
{
host: "A hostname, e.g. 'api1', 'foo.com'"
service: "e.g. 'API port 8000 reqs/sec'",
state: "Any string less than 255 bytes, e.g. 'ok', 'warning', 'critical'",
time: "The time of the event, in unix epoch seconds",
description: "Freeform text",
tags: "Freeform list of strings, e.g. ['rate', 'fooproduct', 'transient']"
metric: "A number associated with this event, e.g. the number of reqs/sec."
ttl: "A floating-point time, in seconds, that this event is considered valid for."
}
Reactors in Godot are readable and writable Stream instances which consume Events and produce actions or aggregate data flow.
There are several core Reactor primatives available in godot
which can be composed to create more complex behavior:
.aggregate()
: Aggregatesmetric
property on events.change(key0, key1, ...)
: Emits events in which any ofkey0 ... keyN
have changed..email(options)
: Sends an email to the specified options..expire(ttl)
: Emits an event when no data is received afterttl
milliseconds..forward(options)
: Forwards all events to a remote server located atoptions.host
andoptions.port
..sms(options)
: Sends an sms to the specified options..where(key, value)|.where(filters)
: Filters events based on a singlekey:value
pair or a set ofkey:value
filters.
Producers in Godot are readable Stream instances which produce Events. Events will be emitted by a given Producer every ttl
milliseconds.
All tests are written in vows and can be run with npm:
npm test