This adds a utility that allows you to output metrics and events to graphite.
Add the following options to your configuration
{
graphite_host: 'graphiteHost', // Hostname for graphite server
graphite_metrics_port: 2003, // Port for metrics submission
graphite_web_port: 80, // Port for graphite web interface(events are submitted this way)
graphite_secure: false // Whether or not to use SSL while submitting events
}
It adds two functions:
writeMetrics(metrics, callback)
metrics is an object containing metric label -> metric data
writeEvent(event, tags, callback)
event is the name of the event
tags is an Array of strings
An example stack would look like this:
var exec = require('child_process').exec;
var async = require('async');
var BuildBot = require('util/buildbot').BuildBot;
var knife = require('util/knife');
var misc = require('util/misc');
var sprintf = require('util/sprintf');
var git = require('util/git');
var Graphite = require('util/graphite').Graphite;
exports.get_deployedRevision = function(args, callback) {
git.revParse(this.config.treslek_dir, 'HEAD', function(err, stdout) {
// trim leading and trailing whitespace
callback(null, stdout.replace(/^\s+|\s+$/g, ''));
});
};
exports.task_deploy = function(stack, baton, args, callback) {
var opts = {cwd: stack.config.treslek_dir, env: process.env},
graphite = new Graphite(stack.config.graphite_host,
stack.config.graphite_metrics_port,
stack.config.graphite_web_port,
stack.config.graphite_secure),
deployStartTime = Date.now();
async.series([
function emitStartDeploy(callback) {
baton.log.info('submitting start deploy event to graphite');
graphite.writeEvent("start deploy", ['deploy', 'startDeploy', 'treslek'], callback);
},
function fetch(callback) {
misc.taskSpawn(baton, args, ['git', 'fetch'], opts, callback);
},
function checkout(callback) {
misc.taskSpawn(baton, args, ['git', 'checkout', args.revision], opts, callback);
},
function wait(callback) {
setTimeout(callback, 45000);
},
function emitDeployTime(callback) {
baton.log.info('submitting end deploy event to graphite');
graphite.writeEvent("end deploy", ['deploy', 'endDeploy', 'treslek'], callback);
}
], callback);
};
exports.targets = {
'deploy': [
'task_deploy',
]
};
This will result in two events being sent to graphite marking the start and end of the deploy. They can be graphed with the events function like: drawAsInfinite(events("deploy")). You pass the tags of the events you'd like to graph, or use * to graph all events. The result is something like:
This adds a utility that allows you to output metrics and events to graphite.
Add the following options to your configuration
It adds two functions:
writeMetrics(metrics, callback)
writeEvent(event, tags, callback)
event
is the name of the eventtags
is an Array of stringsAn example stack would look like this:
This will result in two events being sent to graphite marking the start and end of the deploy. They can be graphed with the events function like:
drawAsInfinite(events("deploy"))
. You pass the tags of the events you'd like to graph, or use*
to graph all events. The result is something like: