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

Do not cache so many prometheus metrics #407

Open
olevski opened this issue Sep 26, 2023 · 1 comment
Open

Do not cache so many prometheus metrics #407

olevski opened this issue Sep 26, 2023 · 1 comment

Comments

@olevski
Copy link
Member

olevski commented Sep 26, 2023

Amalthea has a lot of metrics because it creates a new metric for each combination of user and project id.

I did not know this but prometheus caches all these metrics even after they have been scrpated until .remove is called on the metric with the label names that should be removed from the cache.

Without removing this the cache grows and at some point amalthea published 100k-200k metrics at a time.

So we should periodically call .remove on metrics that we do not need anymore. The easiest way to do this is to call this 1 minute after a session is killed. So after a session is removed we call remove for the user id and project id combo of the session. If we call remove immediately then prometheus will not have a chance to scrape the metrics that were generated. That is why we should have a delay. This delay can be configurable with a default of 1 minute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready
Development

No branches or pull requests

1 participant