Skip to content

Commit 5709703

Browse files
authored
Merge pull request #2151 from david-martin/non-map-array-example
docs: Add example for non map Arrays
2 parents 7ab0612 + c1d57de commit 5709703

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

docs/customresourcestate-metrics.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ spec:
109109
- id: 3
110110
value: false
111111
replicas: 1
112+
refs:
113+
- my_other_foo
114+
- foo_2
115+
- foo_with_extensions
112116
status:
113117
phase: Pending
114118
active:
@@ -209,6 +213,42 @@ kube_customresource_ready_count{customresource_group="myteam.io", customresource
209213
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
210214
```
211215

216+
#### Non-map Arrays
217+
218+
```yaml
219+
kind: CustomResourceStateMetrics
220+
spec:
221+
resources:
222+
- groupVersionKind:
223+
group: myteam.io
224+
kind: "Foo"
225+
version: "v1"
226+
labelsFromPath:
227+
name: [metadata, name]
228+
metrics:
229+
- name: "ref_info"
230+
help: "Reference to other Foo"
231+
each:
232+
type: Info
233+
info:
234+
# targeting an array will produce a metric for each element
235+
# labelsFromPath and value are relative to this path
236+
path: [spec, refs]
237+
238+
# if path targets a list of values (e.g. strings or numbers, not objects or maps), individual values can
239+
# referenced by a label using this syntax
240+
labelsFromPath:
241+
ref: []
242+
```
243+
244+
Produces the following metrics:
245+
246+
```prometheus
247+
kube_customresource_ref_info{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1", name="foo",ref="my_other_foo"} 1
248+
kube_customresource_ref_info{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1", name="foo",ref="foo_2"} 1
249+
kube_customresource_ref_info{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1", name="foo",ref="foo_with_extensions"} 1
250+
```
251+
212252
#### VerticalPodAutoscaler
213253

214254
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:

0 commit comments

Comments
 (0)