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).
I'm using metrics-server right now, but it is not best suited for my use case. I came across the note below, here.
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.
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.
- How should one use the kubelet metrics endpoint directly? All examples I've come across use
metrics.k8s.io
. - The other approach is to get
/sys/fs/cgroup/cpu/cpuacct.usage
reading from the docker containers directly, but there needs to be an aggregation layer. How should one design this stats aggregation layer?
Are there other approaches? What is the best recommended way to address my requirement? Thanks.