metrics: add route to query app metrics with the system

This commit is contained in:
Girish Ramakrishnan
2025-07-07 10:09:36 +02:00
parent 24975d670e
commit 369474a0bc
4 changed files with 30 additions and 15 deletions
+8 -12
View File
@@ -364,23 +364,19 @@ async function readSystemFromGraphite(options) {
async function getSystem(options) {
assert.strictEqual(typeof options, 'object');
const systemStats = await readSystemFromGraphite(options);
const result = {};
const appStats = {};
for (const app of await apps.list()) {
appStats[app.id] = await getContainer(app.id, options);
if (options.system) result.system = await readSystemFromGraphite(options);
for (const appId of options.appIds) {
result[appId] = await getContainer(appId, options);
}
const serviceStats = {};
for (const serviceId of await services.listServices()) {
serviceStats[serviceId] = await getContainer(serviceId, options);
for (const serviceId of options.serviceIds) {
result[serviceId] = await getContainer(serviceId, options);
}
return {
system: systemStats, // { cpu, memory, swap, block{Read,Write}{Rate,Total}, network{Read,Write}{Rate,Total}
apps: appStats,
services: serviceStats,
};
return result;
}
async function getSystemStream(options) {