Skip to content

Commit

Permalink
docs(customresourestate): add example to re-expose all VPA metrics
Browse files Browse the repository at this point in the history
Signed-off-by: clavinjune <[email protected]>
  • Loading branch information
clavinjune committed Jan 7, 2025
1 parent 1412eaa commit 89f8110
Showing 1 changed file with 210 additions and 0 deletions.
210 changes: 210 additions & 0 deletions docs/metrics/extend/customresourcestate-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,216 @@ spec:

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`).

#### All VerticalPodAutoscaler Metrics

As an addition for the above configuration, here's the complete `CustomResourceStateMetrics` spec to re-enable all of the VPA metrics which are removed from the list of the default resources:

<details>

<summary>VPA CustomResourceStateMetrics</summary>
```yaml
kind: CustomResourceStateMetrics
spec:
resources:
- groupVersionKind:
group: autoscaling.k8s.io
kind: "VerticalPodAutoscaler"
version: "v1"
labelsFromPath:
namespace: [metadata, namespace]
target_api_version: [spec, targetRef, apiVersion]
target_kind: [spec, targetRef, kind]
target_name: [spec, targetRef, name]
verticalpodautoscaler: [metadata, name]
metricNamePrefix: "kube"
metrics:
# kube_verticalpodautoscaler_annotations
- name: "verticalpodautoscaler_annotations"
help: "Kubernetes annotations converted to Prometheus labels."
each:
type: Info
info:
labelsFromPath:
# annotation_*: [metadata, annotations]
name: [metadata, name]
# kube_verticalpodautoscaler_labels
- name: "verticalpodautoscaler_labels"
help: "Kubernetes labels converted to Prometheus labels."
each:
type: Info
info:
labelsFromPath:
# label_*: [metadata, labels]
name: [metadata, name]
# kube_verticalpodautoscaler_spec_updatepolicy_updatemode
- name: "verticalpodautoscaler_spec_updatepolicy_updatemode"
help: "Update mode of the VerticalPodAutoscaler."
each:
type: StateSet
stateSet:
labelName: "update_mode"
path: [spec, updatePolicy, updateMode]
list: ["Auto", "Initial", "Off", "Recreate"]
# Memory kube_verticalpodautoscaler_spec_resourcepolicy_container_policies_minallowed
- name: "verticalpodautoscaler_spec_resourcepolicy_container_policies_minallowed"
help: "Minimum memory resources the VerticalPodAutoscaler can set for containers matching the name."
commonLabels:
unit: "byte"
resource: "memory"
each:
type: Gauge
gauge:
path: [spec, resourcePolicy, containerPolicies]
labelsFromPath:
container: [containerName]
valueFrom: [minAllowed, memory]
# CPU kube_verticalpodautoscaler_spec_resourcepolicy_container_policies_minallowed
- name: "verticalpodautoscaler_spec_resourcepolicy_container_policies_minallowed"
help: "Minimum cpu resources the VerticalPodAutoscaler can set for containers matching the name."
commonLabels:
unit: "core"
resource: "cpu"
each:
type: Gauge
gauge:
path: [spec, resourcePolicy, containerPolicies]
labelsFromPath:
container: [containerName]
valueFrom: [minAllowed, cpu]
# Memory kube_verticalpodautoscaler_spec_resourcepolicy_container_policies_maxallowed
- name: "verticalpodautoscaler_spec_resourcepolicy_container_policies_maxallowed"
help: "Maximum memory resources the VerticalPodAutoscaler can set for containers matching the name."
commonLabels:
unit: "byte"
resource: "memory"
each:
type: Gauge
gauge:
path: [spec, resourcePolicy, containerPolicies]
labelsFromPath:
container: [containerName]
valueFrom: [maxAllowed, memory]
# CPU kube_verticalpodautoscaler_spec_resourcepolicy_container_policies_maxallowed
- name: "verticalpodautoscaler_spec_resourcepolicy_container_policies_maxallowed"
help: "Maximum cpu resources the VerticalPodAutoscaler can set for containers matching the name."
commonLabels:
unit: "core"
resource: "cpu"
each:
type: Gauge
gauge:
path: [spec, resourcePolicy, containerPolicies]
labelsFromPath:
container: [containerName]
valueFrom: [maxAllowed, cpu]
# Memory kube_verticalpodautoscaler_status_recommendation_containerrecommendations_lowerbound
- name: "verticalpodautoscaler_status_recommendation_containerrecommendations_lowerbound"
help: "Minimum memory resources the container can use before the VerticalPodAutoscaler updater evicts it."
commonLabels:
unit: "byte"
resource: "memory"
each:
type: Gauge
gauge:
path: [status, recommendation, containerRecommendations]
labelsFromPath:
container: [containerName]
valueFrom: [lowerBound, memory]
# CPU kube_verticalpodautoscaler_status_recommendation_containerrecommendations_lowerbound
- name: "verticalpodautoscaler_status_recommendation_containerrecommendations_lowerbound"
help: "Minimum cpu resources the container can use before the VerticalPodAutoscaler updater evicts it."
commonLabels:
unit: "core"
resource: "cpu"
each:
type: Gauge
gauge:
path: [status, recommendation, containerRecommendations]
labelsFromPath:
container: [containerName]
valueFrom: [lowerBound, cpu]
# Memory kube_verticalpodautoscaler_status_recommendation_containerrecommendations_upperbound
- name: "verticalpodautoscaler_status_recommendation_containerrecommendations_upperbound"
help: "Maximum memory resources the container can use before the VerticalPodAutoscaler updater evicts it."
commonLabels:
unit: "byte"
resource: "memory"
each:
type: Gauge
gauge:
path: [status, recommendation, containerRecommendations]
labelsFromPath:
container: [containerName]
valueFrom: [upperBound, memory]
# CPU kube_verticalpodautoscaler_status_recommendation_containerrecommendations_upperbound
- name: "verticalpodautoscaler_status_recommendation_containerrecommendations_upperbound"
help: "Maximum cpu resources the container can use before the VerticalPodAutoscaler updater evicts it."
commonLabels:
unit: "core"
resource: "cpu"
each:
type: Gauge
gauge:
path: [status, recommendation, containerRecommendations]
labelsFromPath:
container: [containerName]
valueFrom: [upperBound, cpu]
# Memory kube_verticalpodautoscaler_status_recommendation_containerrecommendations_target
- name: "verticalpodautoscaler_status_recommendation_containerrecommendations_target"
help: "Target memory resources the VerticalPodAutoscaler recommends for the container."
commonLabels:
unit: "byte"
resource: "memory"
each:
type: Gauge
gauge:
path: [status, recommendation, containerRecommendations]
labelsFromPath:
container: [containerName]
valueFrom: [target, memory]
# CPU kube_verticalpodautoscaler_status_recommendation_containerrecommendations_target
- name: "verticalpodautoscaler_status_recommendation_containerrecommendations_target"
help: "Target cpu resources the VerticalPodAutoscaler recommends for the container."
commonLabels:
unit: "core"
resource: "cpu"
each:
type: Gauge
gauge:
path: [status, recommendation, containerRecommendations]
labelsFromPath:
container: [containerName]
valueFrom: [target, cpu]
# Memory kube_verticalpodautoscaler_status_recommendation_containerrecommendations_uncappedtarget
- name: "verticalpodautoscaler_status_recommendation_containerrecommendations_uncappedtarget"
help: "Target memory resources the VerticalPodAutoscaler recommends for the container ignoring bounds."
commonLabels:
unit: "byte"
resource: "memory"
each:
type: Gauge
gauge:
path: [status, recommendation, containerRecommendations]
labelsFromPath:
container: [containerName]
valueFrom: [uncappedTarget, memory]
# CPU kube_verticalpodautoscaler_status_recommendation_containerrecommendations_uncappedtarget
- name: "verticalpodautoscaler_status_recommendation_containerrecommendations_uncappedtarget"
help: "Target memory resources the VerticalPodAutoscaler recommends for the container ignoring bounds."
commonLabels:
unit: "core"
resource: "cpu"
each:
type: Gauge
gauge:
path: [status, recommendation, containerRecommendations]
labelsFromPath:
container: [containerName]
valueFrom: [uncappedTarget, cpu]
```

<details>

### Metric types

The configuration supports three kind of metrics from the [OpenMetrics specification](https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md).
Expand Down

0 comments on commit 89f8110

Please sign in to comment.