<p>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 <code>/metrics</code> for Prometheus to scrape.</p>

<p>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?</p>

BlueChips23
<p>For most Promtheus targets, metrics are computed at scrape time. Based on <a href="https://github.com/kubernetes/kube-state-metrics/blob/master/main.go" rel="nofollow noreferrer">kube-state-metrics' github</a>, 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)</p>
