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

Cadvisor high cpu fix #288

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

razem-io
Copy link

@razem-io razem-io commented Oct 6, 2023

If I am not mistaken, those settings won't affect the current dashboards at all, while reducing CPU usage of cadvisor by a lot. On my test system, the average CPU usage was reduced from ~7% to ~2%.

All the credit goes to this comment: google/cadvisor#2523 (comment)

image

As a nice side effect, it also seems to reduce the memory needed.

image

@kroese
Copy link

kroese commented Nov 5, 2023

@razem-io You forgot the most important setting discovered in that issue:

store_container_labels=false

Using that one has the biggest impact on CPU usage for me, much more than changing the scrape interval like you did now.

@razem-io
Copy link
Author

razem-io commented Nov 5, 2023

@kroese funny enough that did not change anything for me. I guess it depends on the individual setup. Do you know what the impact is? Not sure if the labels are used somewhere in the dashboard. I can add it, if does not do much.

@kroese
Copy link

kroese commented Nov 5, 2023

@razem-io It does not change anything in the dashboards, so it wouldn't hurt to use this setting as dock-prom is not using the labels that it generates.

Strange that it didnt make any difference in your case. Maybe it depends on the amount of containers for example (I have 70+ running). Or the fact that I collect the data from 3 different remote docker machines over the network, not just from a local instance. But I could see a massive difference in CPU usage after disabling the labels.

@patrontheo
Copy link

patrontheo commented Mar 27, 2024

+1 @razem-io, your solution also helped my to decrease cadvisor CPU usage, thank you!
image

I haven't tried @kroese solution yet

@razem-io
Copy link
Author

@kroese I added your suggestion to the PR. Sorry, I totally forgot about it.

@patrontheo
Copy link

@razem-io unfortunately, adding the - '-store_container_labels=false' will prevent prometheus to have access to the label 'monitoring' that is used in the monitoring containers. Then, the dashboard 'docker containers' will also contains the monitoring containers (which it shouldn't), and the dashboard 'monitor services' will be more or less empty.
@kroese Do you think it is possible to filter the labels that are stored (to keep only container_label_org_label_schema_group and not all the others) ?

@razem-io
Copy link
Author

razem-io commented Apr 3, 2024

@patrontheo thanks! I reverted the commit. Haven't tested it myself yet. Should have done that before pushing the changes.

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.

None yet

3 participants