Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add example for non map Arrays #2151

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading