diff --git a/src/js/client.js b/src/js/client.js index 08e4a9c5b..d9c138f24 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -1440,22 +1440,34 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }; Client.prototype.graphs = function (targets, from, options, callback) { - var config = { - params: { - target: targets, - format: 'json', - from: from - } - }; + // if we have a lot of apps, targets can be very large. node will just disconnect since it exceeds header size + var size = 10, chunks = []; + for (var i = 0; i < targets.length; i += size) { + chunks.push(targets.slice(i, i+size)); + } - if (options.noNullPoints) config.params.noNullPoints = true; + var result = []; + asyncForEach(chunks, function (chunk, iteratorCallback) { + var config = { + params: { + target: chunk, + format: 'json', + from: from + } + }; - get('/api/v1/cloudron/graphs', config, function (error, data, status) { - if (error) return callback(error); - if (status !== 200) return callback(new ClientError(status, data)); + if (options.noNullPoints) config.params.noNullPoints = true; - // the datapoint returned here is an [value, timestamp] - callback(null, data); + get('/api/v1/cloudron/graphs', config, function (error, data, status) { + if (error) return iteratorCallback(error); + if (status !== 200) return iteratorCallback(new ClientError(status, data)); + + // the datapoint returned here is an [value, timestamp] + result = result.concat(data); + iteratorCallback(null); + }); + }, function iteratorDone(error) { + callback(error, result); }); };