Use explicit app graphs api

This commit is contained in:
Johannes Zellner
2022-09-14 13:03:24 +02:00
parent be72bfdb9f
commit 380b41a1b4
2 changed files with 13 additions and 8 deletions

View File

@@ -799,9 +799,8 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
},
show: function () {
// both in minutes
// in minutes
var timePeriod = $scope.graphs.period * 60;
var timeBucketSize = $scope.graphs.period > 24 ? (6*60) : 5;
function fillGraph(canvasId, data, label, chartPropertyName, max) {
if (!data) return; // no data available yet
@@ -871,16 +870,13 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$scope.graphs[chartPropertyName] = new Chart(ctx, { type: 'line', data: graphData, options: options });
}
var memoryQuery = 'summarize(sum(collectd.localhost.table-' + appId + '-memory.gauge-rss, collectd.localhost.table-' + appId + '-memory.gauge-swap), "' + timeBucketSize + 'min", "avg")';
var diskQuery = 'summarize(collectd.localhost.du-' + appId + '.capacity-usage, "' + timeBucketSize + 'min", "avg")';
Client.graphs([ memoryQuery, diskQuery ], '-' + timePeriod + 'min', { appId: appId }, function (error, result) {
Client.getAppGraphs(appId, timePeriod, function (error, result) {
if (error) return console.error(error);
var currentMemoryLimit = $scope.app.memoryLimit || $scope.app.manifest.memoryLimit || (256 * 1024 * 1024);
fillGraph('#graphsMemoryChart', result[0], 'Memory', 'memoryChart', currentMemoryLimit / 1024 / 1024);
fillGraph('#graphsDiskChart', result[1], 'Disk', 'diskChart', 1024 / 1024);
fillGraph('#graphsMemoryChart', result.memory, 'Memory', 'memoryChart', currentMemoryLimit / 1024 / 1024);
fillGraph('#graphsDiskChart', result.disk, 'Disk', 'diskChart', 1024 / 1024);
});
}
};