graphs: directly stream docker stats
docker stats API caches the stat and reading it frequently gives back the same value. this trips our "rate" code into thinking rate is 0. one approach was to persist polling like we do now and ignore entries based on stats.read. this works fine but the streaming approach seems better since we don't need to poll anymore.
This commit is contained in:
+1
-4
@@ -1085,10 +1085,7 @@ 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 intervalMsecs = typeof req.query.intervalMsecs !== 'undefined' ? parseInt(req.query.intervalMsecs, 10) : 5000;
|
||||
if (!intervalMsecs || intervalMsecs < 100) return next(new HttpError(400, 'intervalSecs query param must be atleast 100'));
|
||||
|
||||
const [error, metricStream] = await safe(metrics.getContainerStream(req.resources.app.id, { intervalMsecs }));
|
||||
const [error, metricStream] = await safe(metrics.getContainerStream(req.resources.app.id, {}));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
res.writeHead(200, {
|
||||
|
||||
Reference in New Issue
Block a user