|
46 | 46 | each:
|
47 | 47 | type: Gauge
|
48 | 48 | ...
|
49 |
| - - --resources=certificatesigningrequests,configmaps,cronjobs,daemonsets,deployments,endpoints,foos,horizontalpodautoscalers,ingresses,jobs,limitranges,mutatingwebhookconfigurations,namespaces,networkpolicies,nodes,persistentvolumeclaims,persistentvolumes,poddisruptionbudgets,pods,replicasets,replicationcontrollers,resourcequotas,secrets,services,statefulsets,storageclasses,validatingwebhookconfigurations,volumeattachments,verticalpodautoscalers |
| 49 | + - --resources=certificatesigningrequests,configmaps,cronjobs,daemonsets,deployments,endpoints,foos,horizontalpodautoscalers,ingresses,jobs,limitranges,mutatingwebhookconfigurations,namespaces,networkpolicies,nodes,persistentvolumeclaims,persistentvolumes,poddisruptionbudgets,pods,replicasets,replicationcontrollers,resourcequotas,secrets,services,statefulsets,storageclasses,validatingwebhookconfigurations,volumeattachments |
50 | 50 | ```
|
51 | 51 |
|
52 | 52 | It's also possible to configure kube-state-metrics to run in a `custom-resource-mode` only. In addition to specifying one of `--custom-resource-state-config*` flags, you could set `--custom-resource-state-only` to `true`.
|
@@ -207,6 +207,45 @@ kube_customresource_ready_count{customresource_group="myteam.io", customresource
|
207 | 207 | kube_customresource_ready_count{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1", active="3",custom_metric="yes",foo="bar",name="foo",bar="baz",qux="quxx",type="type-b"} 4
|
208 | 208 | ```
|
209 | 209 |
|
| 210 | +#### VerticalPodAutoscaler |
| 211 | + |
| 212 | +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: |
| 213 | + |
| 214 | +```yaml |
| 215 | +# Using --resource=verticalpodautoscalers, we get the following output: |
| 216 | +# HELP kube_verticalpodautoscaler_annotations Kubernetes annotations converted to Prometheus labels. |
| 217 | +# TYPE kube_verticalpodautoscaler_annotations gauge |
| 218 | +# kube_verticalpodautoscaler_annotations{namespace="default",verticalpodautoscaler="hamster-vpa",target_api_version="apps/v1",target_kind="Deployment",target_name="hamster"} 1 |
| 219 | +# A similar result can be achieved by specifying the following in --custom-resource-state-config: |
| 220 | +kind: CustomResourceStateMetrics |
| 221 | +spec: |
| 222 | + resources: |
| 223 | + - groupVersionKind: |
| 224 | + group: autoscaling.k8s.io |
| 225 | + kind: "VerticalPodAutoscaler" |
| 226 | + version: "v1" |
| 227 | + labelsFromPath: |
| 228 | + verticalpodautoscaler: [metadata, name] |
| 229 | + namespace: [metadata, namespace] |
| 230 | + target_api_version: [apiVersion] |
| 231 | + target_kind: [spec, targetRef, kind] |
| 232 | + target_name: [spec, targetRef, name] |
| 233 | + metrics: |
| 234 | + - name: "annotations" |
| 235 | + help: "Kubernetes annotations converted to Prometheus labels." |
| 236 | + each: |
| 237 | + type: Gauge |
| 238 | + gauge: |
| 239 | + path: [metadata, annotations] |
| 240 | +# This will output the following metric: |
| 241 | +# HELP kube_customresource_autoscaling_annotations Kubernetes annotations converted to Prometheus labels. |
| 242 | +# TYPE kube_customresource_autoscaling_annotations gauge |
| 243 | +# 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 |
| 244 | +``` |
| 245 | + |
| 246 | +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`). |
| 247 | + |
| 248 | + |
210 | 249 | ### Metric types
|
211 | 250 |
|
212 | 251 | The configuration supports three kind of metrics from the [OpenMetrics specification](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md).
|
|
0 commit comments