graphs: make the interval configurable
This commit is contained in:
@@ -119,11 +119,11 @@ async function getLogStream(req, res, next) {
|
||||
}
|
||||
|
||||
async function getMetrics(req, res, next) {
|
||||
if (!req.query.fromSecs || !parseInt(req.query.fromSecs)) return next(new HttpError(400, 'fromSecs must be a number'));
|
||||
if (!req.query.intervalSecs || !parseInt(req.query.intervalSecs)) return next(new HttpError(400, 'intervalSecs must be a number'));
|
||||
if (!req.query.fromSecs || !parseInt(req.query.fromSecs, 10)) return next(new HttpError(400, 'fromSecs must be a number'));
|
||||
if (!req.query.intervalSecs || !parseInt(req.query.intervalSecs, 10)) return next(new HttpError(400, 'intervalSecs must be a number'));
|
||||
|
||||
const fromSecs = parseInt(req.query.fromSecs);
|
||||
const intervalSecs = parseInt(req.query.intervalSecs);
|
||||
const fromSecs = parseInt(req.query.fromSecs, 10);
|
||||
const intervalSecs = parseInt(req.query.intervalSecs, 10);
|
||||
const noNullPoints = !!req.query.noNullPoints;
|
||||
const [error, result] = await safe(metrics.getSystem({ fromSecs, intervalSecs, noNullPoints }));
|
||||
if (error) return next(new HttpError(500, error));
|
||||
@@ -134,7 +134,10 @@ async function getMetrics(req, res, next) {
|
||||
async function getMetricStream(req, res, next) {
|
||||
if (req.headers.accept !== 'text/event-stream') return next(new HttpError(400, 'This API call requires EventStream'));
|
||||
|
||||
const [error, metricStream] = await safe(metrics.getSystemStream());
|
||||
const intervalSecs = typeof req.query.intervalSecs !== 'undefined' ? parseInt(req.query.intervalSecs, 10) : 5;
|
||||
if (!intervalSecs || intervalSecs < 2) return next(new HttpError(400, 'intervalSecs query param must be >= 2'));
|
||||
|
||||
const [error, metricStream] = await safe(metrics.getSystemStream({ intervalSecs }));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
res.writeHead(200, {
|
||||
|
||||
Reference in New Issue
Block a user