Skip to content

Commit

Permalink
HTTPS data in graphs (#118)
Browse files Browse the repository at this point in the history
* New https data now in graphs
* Update submodule
  • Loading branch information
sjanuary authored and hhellyer committed Oct 5, 2017
1 parent ff3260f commit 2e47fc7
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 5 deletions.
56 changes: 56 additions & 0 deletions lib/appmetrics-dash.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var latestGCEvent;
var latestLoopEvent;
var aggregateHttpEvent;
var aggregateHttpOutboundEvent;
var aggregateHttpsEvent;
var aggregateHttpsOutboundEvent;
var aggregateProbeEvents = [];
// Used for top 5 response times
var httpURLData = {};
Expand Down Expand Up @@ -313,6 +315,34 @@ exports.monitor = function(options) {

});

monitoring.on('https', function(data) {
if (!aggregateHttpsEvent) {
aggregateHttpsEvent = {};
aggregateHttpsEvent.total = 1;
aggregateHttpsEvent.average = data.duration;
aggregateHttpsEvent.longest = data.duration;
aggregateHttpsEvent.time = data.time;
aggregateHttpsEvent.url = data.url;
} else {
aggregateHttpsEvent.total = aggregateHttpsEvent.total + 1;
aggregateHttpsEvent.average = (aggregateHttpsEvent.average * (aggregateHttpsEvent.total - 1) + data.duration) / aggregateHttpsEvent.total;
if (data.duration > aggregateHttpsEvent.longest) {
aggregateHttpsEvent.longest = data.duration;
aggregateHttpsEvent.url = data.url;
}
}

if (httpURLData.hasOwnProperty(data.url)) {
var urlData = httpURLData[data.url];
// Recalculate the average
urlData.duration = (urlData.duration * urlData.hits + data.duration) / (urlData.hits + 1);
urlData.hits = urlData.hits + 1;
} else {
httpURLData[data.url] = {duration: data.duration, hits: 1};
}

});

monitoring.on('http-outbound', function(data) {
if (!aggregateHttpOutboundEvent) {
aggregateHttpOutboundEvent = {};
Expand All @@ -331,6 +361,24 @@ exports.monitor = function(options) {
}
});

monitoring.on('https-outbound', function(data) {
if (!aggregateHttpsOutboundEvent) {
aggregateHttpsOutboundEvent = {};
aggregateHttpsOutboundEvent.total = 1;
aggregateHttpsOutboundEvent.average = data.duration;
aggregateHttpsOutboundEvent.longest = data.duration;
aggregateHttpsOutboundEvent.time = data.time;
aggregateHttpsOutboundEvent.url = data.url;
} else {
aggregateHttpsOutboundEvent.total = aggregateHttpsOutboundEvent.total + 1;
aggregateHttpsOutboundEvent.average = (aggregateHttpsOutboundEvent.average * (aggregateHttpsOutboundEvent.total - 1) + data.duration) / aggregateHttpsOutboundEvent.total;
if (data.duration > aggregateHttpsOutboundEvent.longest) {
aggregateHttpsOutboundEvent.longest = data.duration;
aggregateHttpsOutboundEvent.url = data.url;
}
}
});

monitoring.on('mongo', function(data) {
addProbeEvent('MongoDB', data);
});
Expand Down Expand Up @@ -399,6 +447,10 @@ function emitData() {
io.emit('http', JSON.stringify(aggregateHttpEvent));
aggregateHttpEvent = null;
}
if (aggregateHttpsEvent) {
io.emit('https', JSON.stringify(aggregateHttpsEvent));
aggregateHttpsEvent = null;
}
if (latestGCEvent) {
io.emit('gc', JSON.stringify(latestGCEvent));
latestGCEvent = null;
Expand All @@ -407,6 +459,10 @@ function emitData() {
io.emit('http-outbound', JSON.stringify(aggregateHttpOutboundEvent));
aggregateHttpOutboundEvent = null;
}
if (aggregateHttpsOutboundEvent) {
io.emit('https-outbound', JSON.stringify(aggregateHttpsOutboundEvent));
aggregateHttpsOutboundEvent = null;
}
if (aggregateProbeEvents.length > 0) {
io.emit('probe-events', JSON.stringify(aggregateProbeEvents));
aggregateProbeEvents = [];
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "appmetrics-dash",
"version": "3.3.3",
"version": "3.3.4",
"description": "Embedded monitoring dashboard for Node.js applications.",
"main": "index.js",
"dependencies": {
"appmetrics": "^3.0.1",
"appmetrics": "^3.1.0",
"debug": "^2.6.0",
"express": "^4.14.1",
"express-basic-auth": "^1.0.1",
Expand Down
10 changes: 8 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ <h4 class="modal-title" font-color=black>Heap Snapshot</h4>
<script type="text/javascript" src="graphmetrics/js/envTable.js"></script>
<script type="text/javascript" src="graphmetrics/js/cpuChart.js"></script>

<script type="text/javascript" src="graphmetrics/js/httpRequestsChart.js"></script>
<script type="text/javascript" src="graphmetrics/js/httpHttpsRequestsChart.js"></script>
<script type="text/javascript" src="graphmetrics/js/httpThroughPutChart.js"></script>
<script type="text/javascript" src="graphmetrics/js/httpTop5.js"></script>
<script type="text/javascript" src="graphmetrics/js/httpOutboundRequestsChart.js"></script>
<script type="text/javascript" src="graphmetrics/js/httpHttpsOutboundRequestsChart.js"></script>

<script type="text/javascript" src="graphmetrics/js/memChart.js"></script>
<script type="text/javascript" src="graphmetrics/js/gcChart.js"></script>
Expand Down Expand Up @@ -200,6 +200,12 @@ <h4 class="modal-title" font-color=black>Heap Snapshot</h4>
socket.on('http', function(data) {
updateHttpData(data);
});
socket.on('https-outbound', function(data) {
updateHttpsOBData(data);
});
socket.on('https', function(data) {
updateHttpsData(data);
});
setHttpTop5Options({host: hostname, filteredPath: dashboardRoot});
socket.on('http-urls', function(data) {
updateURLData(data);
Expand Down

0 comments on commit 2e47fc7

Please sign in to comment.