Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set container collector prefix based on owner property #716

Merged

Conversation

jsturtevant
Copy link
Contributor

This updates the container_id label for the metrics reported by the container collector to use the owner ref which is set by docker and containerd respectively.

When running the windows_exporter with the container collector running with a containerd runtime the output of the metrics prefixes the metrics container_id label with docker:// but it should be containerd:// to match other tooling.

Current output:

windows_container_available{container_id="docker://130d82553c53d017649b7115a4e58a8007eef0641ce8804bfb6eb7dcc70ef18b", instance="10.240.0.65:5000", job="windows-exporter"}

If you use hcsdiag list on the host to see the owner ref it specifies the containerd shim as the owner:

hcsdiag list
130d82553c53d017649b7115a4e58a8007eef0641ce8804bfb6eb7dcc70ef18b
    Windows Server Container,   Running,                                     , containerd-shim-runhcs-v1.exe

This is important for jobs that match against container_id to gather more stats from tools like kube-state-metrics which specifies containerd for the contianerid:

kube_pod_container_info{container="iis", container_id="containerd://130d82553c53d017649b7115a4e58a8007eef0641ce8804bfb6eb7dcc70ef18b", image="mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019", image_id="mcr.microsoft.com/windows/servercore/iis@sha256:4763a2b3029259a9fd05168d3963493cbf245b535e02dc80e1eaf1dc51645a05", instance="10.240.0.39:8443", job="kube-state-metrics", namespace="default", pod="iis-1809-668c5b9c87-t5z66"}

For example, a promethues rule from the kubernetes-mixin project:

windows_container_available{%(wmiExporterSelector)s} * on(container_id) group_left(container, pod, namespace) max(kube_pod_container_info{%(kubeStateMetricsSelector)s}) by(container, container_id, pod, namespace)
            ||| % $._config,

Copy link
Contributor

@breed808 breed808 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this James!
I've included a couple minor comments, have a look and let me know if there's any issues.

collector/container.go Outdated Show resolved Hide resolved
collector/container.go Outdated Show resolved Hide resolved
@jsturtevant jsturtevant force-pushed the add-containerd-support branch 2 times, most recently from 7f50765 to 83feb77 Compare February 3, 2021 18:50
Signed-off-by: James Sturtevant <[email protected]>
Copy link
Contributor

@breed808 breed808 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@breed808 breed808 merged commit 0af38dd into prometheus-community:master Feb 4, 2021
anubhavg-icpl pushed a commit to anubhavg-icpl/windows_exporter that referenced this pull request Sep 22, 2024
…ainerd-support

Set container collector prefix based on owner property
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.

2 participants