kubernetes / autoscaler

Autoscaling components for Kubernetes
Apache License 2.0
8.05k stars 3.97k forks source link

[VPA] Prometheus query to get VPA recommendation #3739

Closed dudicoco closed 3 years ago

dudicoco commented 3 years ago

Hi,

Is there a Prometheus query which could fetch the VPA recommendations so that they could be used in Grafana/alerting? I've looked into the code and it doesn't seem that the VPA exposes such metrics. Perhaps we need to use the metrics exposed by kube-state-metrics? Even better, is there a way to calculate the recommendation in a Prometheus query without using the VPA, just according to the historical usage?

Thanks!

bskiba commented 3 years ago

In general we avoid exposing metrics that can be labeled with arbitrary strings (in the case of recommendation it would be vpa-name as a label). Reason being that it's not scalable and causes issues in presence of more objects.

kube-state-metrics indeed exposes these metrics, so it seems like a good fit - https://github.com/kubernetes/kube-state-metrics/blob/master/docs/verticalpodautoscaler-metrics.md.

I don't see a way to translate the recommendation algorithm into a prometheus query.

dudicoco commented 3 years ago

Thanks @bskiba!