Skip to main content

Function: statsContainer()

statsContainer(engineId, id, callback): Promise<Disposable>

Get the streamed stats of a running container.

Parameters

engineId: string

the id of the engine managing the container, obtained from the result of containerEngine.listContainers

id: string

the id or name of the container on this engine, obtained from the result of containerEngine.listContainers or as the result of containerEngine.createContainer

callback

the function called when container stats info are emitted.

Returns

Promise<Disposable>

A Promise resolving a Disposable that unregister the callback when called.

Example

Here is a usage example

const disposable = await statsContainer('engineId', 'containerId', (stats: ContainerStatsInfo): void => {
console.log('CPU Usage', stats.cpu_stats.cpu_usage.total_usage);
});

// When no longer needed
disposable.dispose();

Defined in

packages/extension-api/src/extension-api.d.ts:3777