Portal Community

When to Use

  This node retrieves a single-sample snapshot of container stats (non-streaming mode). CPU percentage is calculated from the delta between two internal counter readings taken at the moment of the API call. For sustained monitoring, call this node on a repeating schedule workflow rather than attempting to stream live data.

Configuration

Connection Fields

FieldTypeDefaultDescription
dockerHoststringunix:///var/run/docker.sockDocker socket path or TCP endpoint
connectionTypestringunixsocketunixsocket | tcp | tcptls
tlsCertPathstringTLS certificate directory. Required for tcptls. optional
timeoutSecondsint30Operation timeout. Stats collection may take 1-2 seconds for CPU delta calculation. optional

Operation Fields

FieldTypeRequiredDescription
resourcestringrequiredMust be container
operationstringrequiredMust be stats
ContainerIdstringrequiredContainer ID or name. Container must be running.

Sample Configuration

{
  "resource": "container",
  "operation": "stats",
  "ContainerId": "api-service",
  "connection": {
    "dockerHost": "unix:///var/run/docker.sock",
    "connectionType": "unixsocket",
    "timeoutSeconds": 10
  }
}

Validation Errors

Error CodeTriggerResolution
MISSING_INPUTContainerId is emptyProvide the container name or ID.
NOT_FOUNDContainer does not existVerify the container name. Use container/list to enumerate available containers.
CONFLICTContainer is not runningStats are only available for running containers. Check state with container/inspect first.
DOCKER_API_ERRORDaemon error retrieving statsCheck daemon logs. Can occur on very new containers before their cgroup metrics are initialized.

Output

Success Port

FieldTypeDescription
cpuPercentnumberCPU usage as a percentage (0–100). Calculated from cgroup counters.
memoryUsagenumberCurrent memory usage in bytes
memoryLimitnumberMemory limit in bytes (configured via container create or host limit)
memoryPercentnumberMemory usage as a percentage of the limit (0–100)
networkInnumberTotal bytes received over all network interfaces since container start
networkOutnumberTotal bytes transmitted over all network interfaces since container start
blockReadnumberTotal bytes read from block devices since container start
blockWritenumberTotal bytes written to block devices since container start
pidsnumberNumber of processes currently running inside the container
statusstringsuccess
resourcestringcontainer
operationstringstats

Error Port

On failure, the error port receives errorCode, message, resource, and operation. In monitoring workflows, a stats retrieval failure should trigger an alert — if stats cannot be read, the container's health is unknown.

Sample Output

{
  "cpuPercent": 12.4,
  "memoryUsage": 157286400,
  "memoryLimit": 536870912,
  "memoryPercent": 29.3,
  "networkIn": 10485760,
  "networkOut": 5242880,
  "blockRead": 2097152,
  "blockWrite": 8388608,
  "pids": 4,
  "status": "success",
  "resource": "container",
  "operation": "stats"
}

Expression Reference

ExpressionReturns
{{ $output.cpuPercent }}CPU usage percentage (e.g. 12.4)
{{ $output.cpuPercent > 85 }}Boolean — true if CPU is above 85%
{{ $output.memoryPercent }}Memory usage as percentage of limit
{{ $output.memoryPercent > 80 }}Boolean — true if memory is above 80% of limit
{{ ($output.memoryUsage / 1048576).toFixed(1) }}Memory usage in MB (human-readable)
{{ ($output.memoryLimit / 1048576).toFixed(0) }}Memory limit in MB
{{ ($output.networkIn / 1048576).toFixed(2) }}Network in, megabytes
{{ $output.pids }}Number of processes in the container

Node Policies & GuardRails

PolicyDetail
Stats only available for running containersAlways verify container state with container/inspect before calling stats in workflows where the container may not be running.
Use scheduled triggers for continuous monitoringBuild resource monitoring by coupling this node with a ScheduledTrigger. Do not attempt to loop inside a single workflow execution for streaming-style monitoring.
Memory limit interpretationIf memoryLimit equals a very large number (e.g. system RAM total), no container-level memory limit has been set. Alert thresholds based on memoryPercent may not be meaningful in this case.
No remote TCP without TLSUse tcptls for remote Docker hosts.
Always wire the error portIn monitoring workflows, stats failure indicates an unknown health state — route the error port to an alert, not a silent skip.

Examples

Example 1: Alert on high CPU usage

// Scheduled trigger: every 2 minutes
// Node 1: container/stats
{ "resource": "container", "operation": "stats", "ContainerId": "api-service" }

// Node 2: If Condition
// Left:  {{ $output.cpuPercent }}
// Op:    greater than
// Right: 85
// → true branch: Slack alert "api-service CPU at {{ $output.cpuPercent.toFixed(1) }}%"
// → false branch: no-op

Example 2: Memory threshold auto-restart

// Node 1: container/stats
{ "resource": "container", "operation": "stats", "ContainerId": "worker-service" }

// Node 2: If Condition — memoryPercent > 90
// → true: container/restart worker-service, then Slack: "worker-service restarted due to memory pressure"
// → false: log metrics and continue

Example 3: Multi-container resource report

// For each container in a known list, collect stats and build a report:
const stats = $input; // output from container/stats loop
return {
  reportLine: `${$vars.containerName}: CPU=${stats.cpuPercent.toFixed(1)}% | ` +
    `Mem=${(stats.memoryUsage/1048576).toFixed(0)}MB/${(stats.memoryLimit/1048576).toFixed(0)}MB ` +
    `(${stats.memoryPercent.toFixed(1)}%) | PIDs=${stats.pids}`
};
// Aggregate lines and send as single Slack or email digest