For how long does kube-state-metrics keep the metrics in its memory?

10/15/2018

From what I understand, kube-state-metrics keeps an in-memory cache of all the kubernetes events related to deployments, nodes and pods and more, and exposes them to /metrics for Prometheus to scrape.

How long does the kube-state-metrics keep these metrics in-memory? Is it indefinitely? Or does it internally clean the cache once a while?

-- BlueChips23
kubernetes
prometheus

1 Answer

10/15/2018

For most Promtheus targets, metrics are computed at scrape time. Based on kube-state-metrics' github, it looks like Kubernetes' implementation is no different. This means that the metrics are not cached, but rather calculated each time that the Prometheus server scrapes the endpoint (or each time you visit /metrics in your browser)

-- wbh1
Source: StackOverflow