Skip to content

Commit 488c0bc

Browse files
committed
update crd monitoring and mention new flags
1 parent 771f85c commit 488c0bc

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed

docs/customresourcestate-metrics.md

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,40 @@ spec:
4949
- --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
5050
```
5151
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`.
53+
With this configuration only the known custom resources configured in `--custom-resource-state-config*` will be taken into account by kube-state-metrics.
54+
55+
```yaml
56+
apiVersion: apps/v1
57+
kind: Deployment
58+
metadata:
59+
name: kube-state-metrics
60+
namespace: kube-system
61+
spec:
62+
template:
63+
spec:
64+
containers:
65+
- name: kube-state-metrics
66+
args:
67+
- --custom-resource-state-config
68+
# in YAML files, | allows a multi-line string to be passed as a flag value
69+
# see https://yaml-multiline.info
70+
- |
71+
spec:
72+
resources:
73+
- groupVersionKind:
74+
group: myteam.io
75+
version: "v1"
76+
kind: Foo
77+
metrics:
78+
- name: active_count
79+
help: "Count of active Foo"
80+
each:
81+
type: Gauge
82+
...
83+
- --custom-resource-state-only=true
84+
```
85+
5286
NOTE: The `customresource_group`, `customresource_version`, and `customresource_kind` common labels are reserved, and will be overwritten by the values from the `groupVersionKind` field.
5387

5488
### Examples
@@ -117,7 +151,7 @@ spec:
117151
Produces the metric:
118152

119153
```prometheus
120-
kube_customresource_uptime{customresource_group="myteam.io", kind="Foo", version="v1"} 43.21
154+
kube_customresource_uptime{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1"} 43.21
121155
```
122156

123157
#### Multiple Metrics/Kitchen Sink
@@ -169,8 +203,8 @@ spec:
169203
Produces the following metrics:
170204

171205
```prometheus
172-
kube_customresource_ready_count{customresource_group="myteam.io", kind="Foo", version="v1", active="1",custom_metric="yes",foo="bar",name="foo",bar="baz",qux="quxx",type="type-a"} 2
173-
kube_customresource_ready_count{customresource_group="myteam.io", kind="Foo", version="v1", active="3",custom_metric="yes",foo="bar",name="foo",bar="baz",qux="quxx",type="type-b"} 4
206+
kube_customresource_ready_count{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1", active="1",custom_metric="yes",foo="bar",name="foo",bar="baz",qux="quxx",type="type-a"} 2
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
174208
```
175209

176210
### Metric types
@@ -205,7 +239,7 @@ spec:
205239
Produces the metric:
206240

207241
```prometheus
208-
kube_customresource_uptime{customresource_group="myteam.io", kind="Foo", version="v1"} 43.21
242+
kube_customresource_uptime{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1"} 43.21
209243
```
210244

211245
#### StateSet
@@ -237,9 +271,9 @@ The value will be 1, if the value matches the one in list.
237271
Produces the metric:
238272

239273
```prometheus
240-
kube_customresource_status_phase{customresource_group="myteam.io", kind="Foo", version="v1", phase="Pending"} 1
241-
kube_customresource_status_phase{customresource_group="myteam.io", kind="Foo", version="v1", phase="Bar"} 0
242-
kube_customresource_status_phase{customresource_group="myteam.io", kind="Foo", version="v1", phase="Baz"} 0
274+
kube_customresource_status_phase{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1", phase="Pending"} 1
275+
kube_customresource_status_phase{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1", phase="Bar"} 0
276+
kube_customresource_status_phase{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1", phase="Baz"} 0
243277
```
244278

245279
#### Info
@@ -269,7 +303,7 @@ spec:
269303
Produces the metric:
270304

271305
```prometheus
272-
kube_customresource_version{customresource_group="myteam.io", kind="Foo", version="v1", version="v1.2.3"} 1
306+
kube_customresource_version{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1", version="v1.2.3"} 1
273307
```
274308

275309
### Naming
@@ -291,7 +325,7 @@ spec:
291325

292326
Produces:
293327
```prometheus
294-
myteam_foos_uptime{customresource_group="myteam.io", kind="Foo", version="v1"} 43.21
328+
myteam_foos_uptime{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1"} 43.21
295329
```
296330

297331
To omit namespace and/or subsystem altogether, set them to the empty string:
@@ -309,7 +343,7 @@ spec:
309343

310344
Produces:
311345
```prometheus
312-
uptime{group="myteam.io", kind="Foo", version="v1"} 43.21
346+
uptime{customresource_group="myteam.io", customresource_kind="Foo", customresource_version="v1"} 43.21
313347
```
314348

315349
### Logging

0 commit comments

Comments
 (0)