From 89f8110d61dc2a19c8517a34b68591e5bcee1d9c Mon Sep 17 00:00:00 2001 From: clavinjune <24659468+clavinjune@users.noreply.github.com> Date: Tue, 7 Jan 2025 16:51:46 +0700 Subject: [PATCH] docs(customresourestate): add example to re-expose all VPA metrics Signed-off-by: clavinjune <24659468+clavinjune@users.noreply.github.com> --- .../extend/customresourcestate-metrics.md | 210 ++++++++++++++++++ 1 file changed, 210 insertions(+) diff --git a/docs/metrics/extend/customresourcestate-metrics.md b/docs/metrics/extend/customresourcestate-metrics.md index 950a31e00..fd1e016f0 100644 --- a/docs/metrics/extend/customresourcestate-metrics.md +++ b/docs/metrics/extend/customresourcestate-metrics.md @@ -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: + +
+ + VPA CustomResourceStateMetrics +```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] +``` + +
+ ### 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).