<p>My use case is to make a kubernetes pod's metrics be available for consumption every 2 secs. It is required to poll the pod at this interval to maintain a healthy control plane (determine pods that are possibly choked and avoid routing traffic to those endpoints).</p>
<p>I'm using metrics-server right now, but it is not best suited for my use case.
I came across the note below, <a href="https://github.com/kubernetes-sigs/metrics-server" rel="nofollow noreferrer">here</a>.</p>
<blockquote>
<p>Metrics Server is not meant for non-autoscaling purposes. For example,
don't use it to forward metrics to monitoring solutions, or as a
source of monitoring solution metrics. In such cases please collect
metrics from Kubelet /metrics/resource endpoint directly.</p>
<p>How often metrics are scraped? Default 60 seconds, can be changed
using metric-resolution flag. We are not recommending setting values
below 15s, as this is the resolution of metrics calculated by Kubelet.</p>
</blockquote>
<ol>
<li>How should one use the kubelet metrics endpoint directly? All examples I've come across use <code>metrics.k8s.io</code>.</li>
<li>The other approach is to get <code>/sys/fs/cgroup/cpu/cpuacct.usage</code> reading from the docker containers directly, but there needs to be an aggregation layer. How should one design this stats aggregation layer?</li>
</ol>
<p>Are there other approaches? What is the best recommended way to address my requirement? Thanks.</p>

<p>I think the easiest would be to add a /metrics endpoint on your workloads and then scrape that using <a href="https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus" rel="nofollow noreferrer">prometheus</a> and the implement the <a href="https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus-adapter" rel="nofollow noreferrer">prometheus adapter</a> to plug into HPA.</p>
