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

Drops image label in container_memory_working_set_bytes metric #1435

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wrbbz
Copy link
Contributor

@wrbbz wrbbz commented May 21, 2024

In according to documentation, container_memory_working_set_bytes has only three labels (by default):

  • container
  • pod
  • namespace

Thus, image label was deleted from query due to its possible absence

@wrbbz wrbbz changed the title fix(labels): drops image label in container_memory_working_set_bytes metric Drops image label in container_memory_working_set_bytes metric May 21, 2024
@arikalon1
Copy link
Contributor

hey @wrbbz

we filter on the label to prevent incorrectly doubling the metric (see stackoverflow below)
https://stackoverflow.com/questions/69281327/why-container-memory-usage-is-doubled-in-cadvisor-metrics

Are you scraping this from cadvisor? What version? What is your prometheus distribution? (kube-prometheus-stack? other?) And do you have any metric_relabel_configs?

@wrbbz
Copy link
Contributor Author

wrbbz commented May 24, 2024

Yeah

I'm using Prometheus installed in k8s cluster. Prom version in 2.45.2.
This metric has these labels: container_memory_working_set_bytes{container="", instance="", job="", namespace="", node="", pod="", scrape_endpoint="cadvisor", tier=""}

Also, there is a relabeling rules:

* Renamed labels:
  * pod_name -> pod
  * container_name -> container
* Dropped labels (id, image, name)
* Dropped metrics w/o labels pod, container or namespace

However, according to Kubernetes Metrics specification, container_memory_working_set_bytes has only three labels:
image

Also, according to the answer on stack overflow, there would not be any doubling due to excluded metrics without container label:

sum(container_memory_working_set_bytes{namespace="$namespace", pod=~"$pod", container!=""}) by (pod, job)

and

sum(container_memory_working_set_bytes{namespace="$namespace", pod=~"$pod", container=~"$container"}) by (container, pod, job)

Part of the answer:

There are multiple ways to fix the problem. For example, you can exclude metrics without container name by using container!="" label filter.

@wrbbz
Copy link
Contributor Author

wrbbz commented Jun 3, 2024

@arikalon1, what do you think?

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