Skip to content

Commit f34ba86

Browse files
committed
docs: updated VPA CustomResourceStateMetrics docs
Signed-off-by: Sherif Ayad <[email protected]>
1 parent 76f42c1 commit f34ba86

File tree

1 file changed

+41
-14
lines changed

1 file changed

+41
-14
lines changed

docs/customresourcestate-metrics.md

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,9 @@ kube_customresource_ref_info{customresource_group="myteam.io", customresource_ki
250250

251251
#### VerticalPodAutoscaler
252252

253-
In v2.9.0 the `vericalpodautoscalers` resource was removed from the list of default resources. In order to generate metrics for `verticalpodautoscalers`, you can use the following Custom Resource State config:
253+
In v2.9.0 the `verticalpodautoscalers` resource was removed from the list of default resources. In order to generate Memory / CPU recommendation metrics for `verticalpodautoscalers`, you can use the following Custom Resource State config:
254254

255255
```yaml
256-
# Using --resource=verticalpodautoscalers, we get the following output:
257-
# HELP kube_verticalpodautoscaler_annotations Kubernetes annotations converted to Prometheus labels.
258-
# TYPE kube_verticalpodautoscaler_annotations gauge
259-
# kube_verticalpodautoscaler_annotations{namespace="default",verticalpodautoscaler="hamster-vpa",target_api_version="apps/v1",target_kind="Deployment",target_name="hamster"} 1
260-
# A similar result can be achieved by specifying the following in --custom-resource-state-config:
261256
kind: CustomResourceStateMetrics
262257
spec:
263258
resources:
@@ -272,19 +267,51 @@ spec:
272267
target_kind: [spec, targetRef, kind]
273268
target_name: [spec, targetRef, name]
274269
metrics:
275-
- name: "annotations"
276-
help: "Kubernetes annotations converted to Prometheus labels."
270+
- name: "vpa_containerrecommendations_target"
271+
help: "VPA container recommendations for memory."
277272
each:
278273
type: Gauge
279274
gauge:
280-
path: [metadata, annotations]
281-
# This will output the following metric:
282-
# HELP kube_customresource_autoscaling_annotations Kubernetes annotations converted to Prometheus labels.
283-
# TYPE kube_customresource_autoscaling_annotations gauge
284-
# kube_customresource_autoscaling_annotations{customresource_group="autoscaling.k8s.io", customresource_kind="VerticalPodAutoscaler", customresource_version="v1", namespace="default",target_api_version="autoscaling.k8s.io/v1",target_kind="Deployment",target_name="hamster",verticalpodautoscaler="hamster-vpa"} 123
275+
path: [status, recommendation, containerRecommendations]
276+
valueFrom: [target, memory]
277+
labelsFromPath:
278+
container: [containerName]
279+
commonLabels:
280+
resource: "memory"
281+
unit: "byte"
282+
- name: "vpa_containerrecommendations_target"
283+
help: "VPA container recommendations for cpu."
284+
each:
285+
type: Gauge
286+
gauge:
287+
path: [status, recommendation, containerRecommendations]
288+
valueFrom: [target, cpu]
289+
labelsFromPath:
290+
container: [containerName]
291+
commonLabels:
292+
resource: "cpu"
293+
unit: "core"
285294
```
286295

287-
The above configuration was tested on [this](https://github.com/kubernetes/autoscaler/blob/master/vertical-pod-autoscaler/examples/hamster.yaml) VPA configuration, with an added annotation (`foo: 123`).
296+
The above configuration was tested on [this](https://github.com/kubernetes/autoscaler/blob/master/vertical-pod-autoscaler/examples/hamster.yaml) VPA configuration, outputting the following metrics:
297+
```
298+
# HELP kube_customresource_vpa_containerrecommendations_target VPA container recommendations for memory.
299+
kube_customresource_vpa_containerrecommendations_target{container="hamster",customresource_group="autoscaling.k8s.io",customresource_kind="VerticalPodAutoscaler",customresource_version="v1",namespace="default",resource="memory",target_api_version="autoscaling.k8s.io/v1",target_kind="Deployment",target_name="hamster",unit="byte",verticalpodautoscaler="hamster-vpa"} 1.048576e+08
300+
301+
# HELP kube_customresource_vpa_containerrecommendations_target VPA container recommendations for cpu.
302+
kube_customresource_vpa_containerrecommendations_target{container="hamster",customresource_group="autoscaling.k8s.io",customresource_kind="VerticalPodAutoscaler",customresource_version="v1",namespace="default",resource="cpu",target_api_version="autoscaling.k8s.io/v1",target_kind="Deployment",target_name="hamster",unit="core",verticalpodautoscaler="hamster-vpa"} 0.1
303+
```
304+
305+
To ensure that the VPA Metrics will be captured seamlessly, make sure that the Cluster Role / Role assigned to the Kube State Metrics has permissions to `list` & `watch` VPA resources e.g.:
306+
```yaml
307+
- verbs:
308+
- list
309+
- watch
310+
apiGroups:
311+
- autoscaling.k8s.io
312+
resources:
313+
- verticalpodautoscalers
314+
```
288315

289316
### Metric types
290317

0 commit comments

Comments
 (0)