Skip to content

Commit

Permalink
Merge pull request #2151 from david-martin/non-map-array-example
Browse files Browse the repository at this point in the history
docs:  Add example for non map Arrays
  • Loading branch information
k8s-ci-robot committed Aug 21, 2023
2 parents 7ab0612 + c1d57de commit 5709703
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions docs/customresourcestate-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ spec:
- id: 3
value: false
replicas: 1
refs:
- my_other_foo
- foo_2
- foo_with_extensions
status:
phase: Pending
active:
Expand Down Expand Up @@ -209,6 +213,42 @@ kube_customresource_ready_count{customresource_group="myteam.io", customresource
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
```

#### Non-map Arrays

```yaml
kind: CustomResourceStateMetrics
spec:
resources:
- groupVersionKind:
group: myteam.io
kind: "Foo"
version: "v1"
labelsFromPath:
name: [metadata, name]
metrics:
- name: "ref_info"
help: "Reference to other Foo"
each:
type: Info
info:
# targeting an array will produce a metric for each element
# labelsFromPath and value are relative to this path
path: [spec, refs]

# if path targets a list of values (e.g. strings or numbers, not objects or maps), individual values can
# referenced by a label using this syntax
labelsFromPath:
ref: []
```

Produces the following metrics:

```prometheus
kube_customresource_ref_info{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1", name="foo",ref="my_other_foo"} 1
kube_customresource_ref_info{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1", name="foo",ref="foo_2"} 1
kube_customresource_ref_info{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1", name="foo",ref="foo_with_extensions"} 1
```

#### VerticalPodAutoscaler

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:
Expand Down

0 comments on commit 5709703

Please sign in to comment.