collectors/cgroups: fix resolving container names in k8s #10072
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes: #10006
Correctly resolve all
kubepods/*
cgroups names when running inside the k8s cluster (http req to the API server) or installed on a k8 node (viakubectl
).New naming format (breaking change):
k8s_pod_<NAMESPACE>_<POD_NAME>
k8s_cntr_<NAMESPACE>_<POD_NAME>_<CONTAINER_NAME>
I don't add filtering to the cgroup-name.sh script, so all level cgroup are collected. I think it is better to have filtering in the cgroups collector configuration options (
enable by default cgroups matching
).This PR doesn't contain
enable by default cgroups matching
option updates, i plan to add them in a separet PR (added in #10095).Cgroup tree structure on the GKE and minikube nodes
This PR handles both cases, if there are other dir names formats it is likely it fails to extract
podUID
orcontainerID
.It is kind of difficult because
cgroups
collector passes a chart.id as an argument => all/
changed to_
(_
is field delimiter...).Component Name
collectors/cgroups
Test Plan
cgroup-name.sh
script to the children nodesdocker restart <CONTAINER_ID>
)kubectl exec ...
into the parent node,rm -rf *
db cacheI see all the
kubepods/*
cgroups on the dashboard.cgroup-name.sh
script to the agentI see all containers level cgroups on the dashboard. Pod and higher level cgroups filtered because of
.slice
suffix which doesn't match default match cgroup name simple pattern.Additional Information