graphs: send service graphs
This commit is contained in:
@@ -58,6 +58,7 @@ exports = module.exports = {
|
||||
updateBackup,
|
||||
|
||||
getLimits,
|
||||
getGraphs,
|
||||
|
||||
load
|
||||
};
|
||||
@@ -68,6 +69,7 @@ const apps = require('../apps.js'),
|
||||
BoxError = require('../boxerror.js'),
|
||||
constants = require('../constants.js'),
|
||||
debug = require('debug')('box:routes/apps'),
|
||||
graphs = require('../graphs.js'),
|
||||
HttpError = require('connect-lastmile').HttpError,
|
||||
HttpSuccess = require('connect-lastmile').HttpSuccess,
|
||||
safe = require('safetydance'),
|
||||
@@ -959,3 +961,16 @@ async function getLimits(req, res, next) {
|
||||
|
||||
next(new HttpSuccess(200, { limits }));
|
||||
}
|
||||
|
||||
async function getGraphs(req, res, next) {
|
||||
assert.strictEqual(typeof req.app, 'object');
|
||||
|
||||
if (!req.query.fromMinutes || !parseInt(req.query.fromMinutes)) return next(new HttpError(400, 'fromMinutes must be a number'));
|
||||
|
||||
const fromMinutes = parseInt(req.query.fromMinutes);
|
||||
const noNullPoints = !!req.query.noNullPoints;
|
||||
const [error, result] = await safe(graphs.getContainerStats(req.app.id, fromMinutes, noNullPoints));
|
||||
if (error) return next(new HttpError(500, error));
|
||||
|
||||
next(new HttpSuccess(200, result));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user