Skip to content

Commit

Permalink
added error history feature
Browse files Browse the repository at this point in the history
  • Loading branch information
agate committed Aug 27, 2013
1 parent 6e9646d commit dd5aaf3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
7 changes: 7 additions & 0 deletions lib/upbeat/meta-data.ms
Expand Up @@ -23,6 +23,9 @@ export class MetaData {

this.totalResTime = 0;
this.totalCount = 0;

this.errorHistory = [];

this.lastErrorMessage = null;
this.lastResponseTime = null;

Expand Down Expand Up @@ -77,6 +80,10 @@ export class MetaData {
this.up = passed;
this.emit('down', error);
this.emit('change');
this.errorHistory.push({
error: error,
timestamp: now
});
}

this.wasUp = passed;
Expand Down
13 changes: 7 additions & 6 deletions lib/upbeat/www/routes/services.ms
Expand Up @@ -6,7 +6,7 @@ module.exports = #(app, upbeat) {
var service = upbeat.getService(req.params.service);
if (! service) {
res.send("Service not found", 404);
return false;
return false;
} else {
return service
}
Expand Down Expand Up @@ -41,23 +41,24 @@ module.exports = #(app, upbeat) {
avgRespTime: action.meta.averageResponseTime(period),
interval: action.interval,
timeout: action.timeout,
passes: action.meta.total('passed-count'),
failures: action.meta.total('failed-count')
passes: action.meta.total('passed-count'),
failures: action.meta.total('failed-count'),
errorHistory: action.meta.errorHistory
},

responseTimes: action.meta.plotResponseTimes('min')
};

res.send(JSON.stringify(ret));
}
}

else {
res.render('action', { action: action, service: service });
}
}
});

app.get('/services/:service/health', #(req, res, next) {
app.get('/services/:service/health', #(req, res, next) {
var service = getService(req, res);
if (service) {
if (service.up) {
Expand Down
31 changes: 26 additions & 5 deletions lib/upbeat/www/views/action.jade
Expand Up @@ -3,7 +3,7 @@ block content
ul.breadcrumb
li
a(href="/services/#{service.name}")= service.name
span.divider /
span.divider /
li.active= action.name


Expand Down Expand Up @@ -31,6 +31,8 @@ block content
th Passed Count
td#passes

h3 Error History
table.table.table-condensed.table-bordered.table-striped#errorHistory

h3 Performance
#container(style="width:100%;height:500px")
Expand All @@ -44,24 +46,43 @@ block content
}

var chart = null;

function updateData(payload) {
var meta = payload.meta;
var data = payload.responseTimes;

for (var k in meta) $('#' + k).html(meta[k]);
for (var k in meta) {
var html = '';

if (k == 'errorHistory') {
html = meta.errorHistory.map(function (e) {
return '<tr>' +
'<td>' + e.error + '</td>' +
'<td>@</td>' +
'<td>' + new Date(e.timestamp) + '</td>' +
'</tr>';
}).join("\n");
}

else {
html = meta[k];
}

$('#' + k).html(html)
}

if (chart) {
chart.series[0].setData(data, true);
return;
}

chart = new Highcharts.Chart({
chart: {
chart: {
renderTo: 'container',
type: 'line'
},
},

xAxis: {
xAxis: {
title: { text: 'Seconds Ago' },
categories: #{categories.min.data}
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -3,7 +3,7 @@
"description": "Fast health and performance monitoring with process handling",
"keywords": ["javascript", "performance", "health", "monitoring", "monit", "haproxy", "forever", "process", "systems"],
"author": "Jeff Su <me@jeffsu.com>",
"version": "0.2.3-pre12",
"version": "0.2.3-pre13",
"licenses": [{ "type": "MIT" }],
"engines": { "node": ">=0.5.0" },
"directories" : { "lib" : "./lib/upbeat" },
Expand Down

0 comments on commit dd5aaf3

Please sign in to comment.