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:
Girish Ramakrishnan
2025-07-03 19:01:40 +02:00
parent 03b7445cb9
commit 813409a8fb
4 changed files with 31 additions and 31 deletions
+1 -4
View File
@@ -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, {