Skip to content

containerd: make the cgroup pattern configurable - #3923

Open
eagletmt wants to merge 1 commit into
google:masterfrom
eagletmt:containerd-cgroup-pattern
Open

containerd: make the cgroup pattern configurable#3923
eagletmt wants to merge 1 commit into
google:masterfrom
eagletmt:containerd-cgroup-pattern

Conversation

@eagletmt

@eagletmt eagletmt commented Aug 7, 2026

Copy link
Copy Markdown

cAdvisor identifies containerd containers by matching the base name of a cgroup against a hardcoded ([a-z0-9]{64}). Deployments that do not name cgroups after the 64 hex character container ID are therefore never claimed by the containerd factory, and fall back to the raw factory, which reports no image, name or labels for them.

AWS ECS Managed Instances is one such deployment: it runs containerd under the fargate.task namespace and names container cgroups /ecs/<32 hex task id>/<32 hex task id>-<digits>.

Add a -containerd_cgroup_pattern flag that overrides the regexp. It defaults to the current pattern, so existing behaviour is unchanged. If the pattern has a capturing group, the first submatch of the base name is used as the containerd container ID; otherwise the base name itself is used, which is what ECS Managed Instances needs because there the cgroup base name already is the container ID.

Per-container metrics on ECS Managed Instances can then be collected with:

cadvisor -containerd-namespace=fargate.task \
    -containerd_cgroup_pattern='^[a-f0-9]{32}-[0-9]+$'

cAdvisor identifies containerd containers by matching the base name of a
cgroup against a hardcoded `([a-z0-9]{64})`. Deployments that do not name
cgroups after the 64 hex character container ID are therefore never
claimed by the containerd factory, and fall back to the raw factory,
which reports no image, name or labels for them.

AWS ECS Managed Instances is one such deployment: it runs containerd
under the `fargate.task` namespace and names container cgroups
`/ecs/<32 hex task id>/<32 hex task id>-<digits>`.

Add a `-containerd_cgroup_pattern` flag that overrides the regexp. It
defaults to the current pattern, so existing behaviour is unchanged. If
the pattern has a capturing group, the first submatch of the base name is
used as the containerd container ID; otherwise the base name itself is
used, which is what ECS Managed Instances needs because there the cgroup
base name already is the container ID.

Per-container metrics on ECS Managed Instances can then be collected
with:

```
cadvisor -containerd-namespace=fargate.task \
    -containerd_cgroup_pattern='^[a-f0-9]{32}-[0-9]+$'
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant