Skip to main content
Version: v3.9.0

Resource consumption

The resource consumption manager samples edgelet stack and host usage against configured limits and publishes results to StatusReporter. It also participates in limit enforcement signaling for the agent.

Code: internal/resourceconsumption/

Purpose​

  • Sample control-plane RSS/CPU via gopsutil (process.MemoryInfo, process.Percent)
  • When containerEngine=edgelet on an embedded build, include the --edgelet-containerd-child data-plane process(es)
  • Compare stack totals against configured limits (bytes / CPU percentage)
  • Update ResourceConsumptionManagerStatus on StatusReporter
  • Collect initial sample immediately on start (no wait for first tick)

Metrics​

FieldMeaning
agentCpu / agentMemoryControl-plane edgelet daemon process (cores / bytes): local API only
runtimeCpu / runtimeMemoryEmbedded containerd child (embedded engine only; cores / bytes): local API only
edgeletStackCpu / edgeletStackMemoryStack totals (cores / bytes): local API only
cpuUsage / memoryUsageEdgelet stack total (agent + runtime when available): also sent to Controller in PUT status. Stack CPU uses per-core scale (100 = one logical CPU); human CLI prints stack breakdown in cores and hides duplicate cpuUsage when edgeletStackCpu is present.
diskUsageEdgelet data directory usage in GiB (not host filesystem total)
systemCpusLogical CPU count
systemOs / systemOsVersion / systemKernelVersionGOOS family (linux, darwin, windows); Linux PRETTY_NAME or platform+version; Linux kernel only ("" on non-Linux)
systemTotalMemory / systemAvailableMemoryHost RAM capacity / free (bytes)
systemTotalDisk / systemAvailableDiskFilesystem of diskDirectory total / free (bytes)
systemTotalCpuHost CPU busy 0-100% (not core count)

External docker / podman engines report agent-only stack totals (no runtime child tracking).

Dependencies​

Depends onReason
statusreporterPublish usage metrics
configLimits and poll frequency
gopsutilProcess and host metrics
pkg/containerdDiscover embedded containerd child PIDs on Linux
Used byReason
supervisorStarted early (before Field Agent)

Lifecycle​

Start​

  1. InstanceConfigUpdated(). Load limits from config
  2. collectUsageData() immediately
  3. Start periodic worker at configured frequency

Config update​

InstanceConfigUpdated() refreshes disk/CPU/memory limits and may restart sampling logic.

Configuration​

Limits loaded from config profile (typical keys):

KeyUnit
Disk limitbytes
Memory limitbytes
CPU limitstack cores × 100 (5-400; default 80 = 0.8 CPU; monitor-only)

Exact YAML names match config.yaml profiles. See default config in internal/config/default_config.yaml.

Module status​

PropertyValue
StatusReporter index0 (utils.ResourceConsumptionManager)
First slot in modulesStatus[]Resource Consumption

Status fields include stack breakdown plus legacy memoryUsage, cpuUsage, diskUsage.

External APIs​

Exposed indirectly via GET /v1/system/status resource section and Controller status POST.

Observability​

  • Log module: "Resource Consumption Manager"
  • Initial and periodic debug logs with MiB/GiB formatting
  • Warn when multiple embedded containerd child PIDs are detected

Failure modes​

SymptomTypical cause
Zero usage reportedgopsutil error on platform
runtimeDegraded=trueEmbedded engine configured but containerd child not running
Limit warningsStack usage exceeded configured thresholds

Code map​

FileRole
manager.goSampling loop, limit comparison, status updates
stats.goParallel process/host sampling and CPU smoothing
runtime_linux.goEmbedded runtime PID discovery
host_cpu_linux.goLinux host CPU fallback

Related: Status reporter, Supervisor.

Group 3See anything wrong with the document? Help us improve it!