You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/concepts/cluster-administration/system-metrics.md
+81-33Lines changed: 81 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,8 @@ weight: 60
10
10
11
11
<!-- overview -->
12
12
13
-
System component metrics can give a better look into what is happening inside them. Metrics are particularly useful for building dashboards and alerts.
13
+
System component metrics can give a better look into what is happening inside them. Metrics are
14
+
particularly useful for building dashboards and alerts.
14
15
15
16
Kubernetes components emit metrics in [Prometheus format](https://prometheus.io/docs/instrumenting/exposition_formats/).
16
17
This format is structured plain text, designed so that people and machines can both read it.
@@ -19,7 +20,8 @@ This format is structured plain text, designed so that people and machines can b
19
20
20
21
## Metrics in Kubernetes
21
22
22
-
In most cases metrics are available on `/metrics` endpoint of the HTTP server. For components that doesn't expose endpoint by default it can be enabled using `--bind-address` flag.
23
+
In most cases metrics are available on `/metrics` endpoint of the HTTP server. For components that
24
+
doesn't expose endpoint by default it can be enabled using `--bind-address` flag.
In a production environment you may want to configure [Prometheus Server](https://prometheus.io/) or some other metrics scraper
33
-
to periodically gather these metrics and make them available in some kind of time series database.
34
+
In a production environment you may want to configure [Prometheus Server](https://prometheus.io/)
35
+
or some other metrics scraper to periodically gather these metrics and make them available in some
36
+
kind of time series database.
34
37
35
-
Note that {{< glossary_tooltip term_id="kubelet" text="kubelet" >}} also exposes metrics in `/metrics/cadvisor`, `/metrics/resource` and `/metrics/probes` endpoints. Those metrics do not have same lifecycle.
38
+
Note that {{< glossary_tooltip term_id="kubelet" text="kubelet" >}} also exposes metrics in
39
+
`/metrics/cadvisor`, `/metrics/resource` and `/metrics/probes` endpoints. Those metrics do not
40
+
have same lifecycle.
41
+
42
+
If your cluster uses {{< glossary_tooltip term_id="rbac" text="RBAC" >}}, reading metrics requires
43
+
authorization via a user, group or ServiceAccount with a ClusterRole that allows accessing
44
+
`/metrics`. For example:
36
45
37
-
If your cluster uses {{< glossary_tooltip term_id="rbac" text="RBAC" >}}, reading metrics requires authorization via a user, group or ServiceAccount with a ClusterRole that allows accessing `/metrics`.
Alpha metrics have no stability guarantees. These metrics can be modified or deleted at any time.
56
63
57
64
Stable metrics are guaranteed to not change. This means:
65
+
58
66
* A stable metric without a deprecated signature will not be deleted or renamed
59
67
* A stable metric's type will not be modified
60
68
@@ -79,45 +87,64 @@ For example:
79
87
some_counter 0
80
88
```
81
89
82
-
Hidden metrics are no longer published for scraping, but are still available for use. To use a hidden metric, please refer to the [Show hidden metrics](#show-hidden-metrics) section.
90
+
Hidden metrics are no longer published for scraping, but are still available for use. To use a
91
+
hidden metric, please refer to the [Show hidden metrics](#show-hidden-metrics) section.
83
92
84
93
Deleted metrics are no longer published and cannot be used.
85
94
86
-
87
95
## Show hidden metrics
88
96
89
-
As described above, admins can enable hidden metrics through a command-line flag on a specific binary. This intends to be used as an escape hatch for admins if they missed the migration of the metrics deprecated in the last release.
97
+
As described above, admins can enable hidden metrics through a command-line flag on a specific
98
+
binary. This intends to be used as an escape hatch for admins if they missed the migration of the
99
+
metrics deprecated in the last release.
90
100
91
-
The flag `show-hidden-metrics-for-version` takes a version for which you want to show metrics deprecated in that release. The version is expressed as x.y, where x is the major version, y is the minor version. The patch version is not needed even though a metrics can be deprecated in a patch release, the reason for that is the metrics deprecation policy runs against the minor release.
101
+
The flag `show-hidden-metrics-for-version` takes a version for which you want to show metrics
102
+
deprecated in that release. The version is expressed as x.y, where x is the major version, y is
103
+
the minor version. The patch version is not needed even though a metrics can be deprecated in a
104
+
patch release, the reason for that is the metrics deprecation policy runs against the minor release.
92
105
93
-
The flag can only take the previous minor version as it's value. All metrics hidden in previous will be emitted if admins set the previous version to `show-hidden-metrics-for-version`. The too old version is not allowed because this violates the metrics deprecated policy.
106
+
The flag can only take the previous minor version as it's value. All metrics hidden in previous
107
+
will be emitted if admins set the previous version to `show-hidden-metrics-for-version`. The too
108
+
old version is not allowed because this violates the metrics deprecated policy.
94
109
95
-
Take metric `A` as an example, here assumed that `A` is deprecated in 1.n. According to metrics deprecated policy, we can reach the following conclusion:
110
+
Take metric `A` as an example, here assumed that `A` is deprecated in 1.n. According to metrics
111
+
deprecated policy, we can reach the following conclusion:
96
112
97
113
* In release `1.n`, the metric is deprecated, and it can be emitted by default.
98
-
* In release `1.n+1`, the metric is hidden by default and it can be emitted by command line `show-hidden-metrics-for-version=1.n`.
114
+
* In release `1.n+1`, the metric is hidden by default and it can be emitted by command line
115
+
`show-hidden-metrics-for-version=1.n`.
99
116
* In release `1.n+2`, the metric should be removed from the codebase. No escape hatch anymore.
100
117
101
-
If you're upgrading from release `1.12` to `1.13`, but still depend on a metric `A` deprecated in `1.12`, you should set hidden metrics via command line: `--show-hidden-metrics=1.12` and remember to remove this metric dependency before upgrading to `1.14`
118
+
If you're upgrading from release `1.12` to `1.13`, but still depend on a metric `A` deprecated in
119
+
`1.12`, you should set hidden metrics via command line: `--show-hidden-metrics=1.12` and remember
120
+
to remove this metric dependency before upgrading to `1.14`
102
121
103
122
## Disable accelerator metrics
104
123
105
-
The kubelet collects accelerator metrics through cAdvisor. To collect these metrics, for accelerators like NVIDIA GPUs, kubelet held an open handle on the driver. This meant that in order to perform infrastructure changes (for example, updating the driver), a cluster administrator needed to stop the kubelet agent.
124
+
The kubelet collects accelerator metrics through cAdvisor. To collect these metrics, for
125
+
accelerators like NVIDIA GPUs, kubelet held an open handle on the driver. This meant that in order
126
+
to perform infrastructure changes (for example, updating the driver), a cluster administrator
127
+
needed to stop the kubelet agent.
106
128
107
-
The responsibility for collecting accelerator metrics now belongs to the vendor rather than the kubelet. Vendors must provide a container that collects metrics and exposes them to the metrics service (for example, Prometheus).
129
+
The responsibility for collecting accelerator metrics now belongs to the vendor rather than the
130
+
kubelet. Vendors must provide a container that collects metrics and exposes them to the metrics
131
+
service (for example, Prometheus).
108
132
109
-
The [`DisableAcceleratorUsageMetrics` feature gate](/docs/reference/command-line-tools-reference/feature-gates/) disables metrics collected by the kubelet, with a [timeline for enabling this feature by default](https://github.com/kubernetes/enhancements/tree/411e51027db842355bd489691af897afc1a41a5e/keps/sig-node/1867-disable-accelerator-usage-metrics#graduation-criteria).
133
+
The [`DisableAcceleratorUsageMetrics` feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
134
+
disables metrics collected by the kubelet, with a
135
+
[timeline for enabling this feature by default](https://github.com/kubernetes/enhancements/tree/411e51027db842355bd489691af897afc1a41a5e/keps/sig-node/1867-disable-accelerator-usage-metrics#graduation-criteria).
110
136
111
137
## Component metrics
112
138
113
139
### kube-controller-manager metrics
114
140
115
-
Controller manager metrics provide important insight into the performance and health of the controller manager.
116
-
These metrics include common Go language runtime metrics such as go_routine count and controller specific metrics such as
117
-
etcd request latencies or Cloudprovider (AWS, GCE, OpenStack) API latencies that can be used
118
-
to gauge the health of a cluster.
141
+
Controller manager metrics provide important insight into the performance and health of the
142
+
controller manager. These metrics include common Go language runtime metrics such as go_routine
143
+
count and controller specific metrics such as etcd request latencies or Cloudprovider (AWS, GCE,
144
+
OpenStack) API latencies that can be used to gauge the health of a cluster.
119
145
120
-
Starting from Kubernetes 1.7, detailed Cloudprovider metrics are available for storage operations for GCE, AWS, Vsphere and OpenStack.
146
+
Starting from Kubernetes 1.7, detailed Cloudprovider metrics are available for storage operations
147
+
for GCE, AWS, Vsphere and OpenStack.
121
148
These metrics can be used to monitor health of persistent volume operations.
The scheduler exposes optional metrics that reports the requested resources and the desired limits of all running pods. These metrics can be used to build capacity planning dashboards, assess current or historical scheduling limits, quickly identify workloads that cannot schedule due to lack of resources, and compare actual usage to the pod's request.
166
+
The scheduler exposes optional metrics that reports the requested resources and the desired limits
167
+
of all running pods. These metrics can be used to build capacity planning dashboards, assess
168
+
current or historical scheduling limits, quickly identify workloads that cannot schedule due to
169
+
lack of resources, and compare actual usage to the pod's request.
170
+
171
+
The kube-scheduler identifies the resource [requests and limits](/docs/concepts/configuration/manage-resources-containers/)
172
+
configured for each Pod; when either a request or limit is non-zero, the kube-scheduler reports a
173
+
metrics timeseries. The time series is labelled by:
140
174
141
-
The kube-scheduler identifies the resource [requests and limits](/docs/concepts/configuration/manage-resources-containers/) configured for each Pod; when either a request or limit is non-zero, the kube-scheduler reports a metrics timeseries. The time series is labelled by:
142
175
- namespace
143
176
- pod name
144
177
- the node where the pod is scheduled or an empty string if not yet scheduled
@@ -147,32 +180,47 @@ The kube-scheduler identifies the resource [requests and limits](/docs/concepts/
147
180
- the name of the resource (for example, `cpu`)
148
181
- the unit of the resource if known (for example, `cores`)
149
182
150
-
Once a pod reaches completion (has a `restartPolicy` of `Never` or `OnFailure` and is in the `Succeeded` or `Failed` pod phase, or has been deleted and all containers have a terminated state) the series is no longer reported since the scheduler is now free to schedule other pods to run. The two metrics are called `kube_pod_resource_request` and `kube_pod_resource_limit`.
183
+
Once a pod reaches completion (has a `restartPolicy` of `Never` or `OnFailure` and is in the
184
+
`Succeeded` or `Failed` pod phase, or has been deleted and all containers have a terminated state)
185
+
the series is no longer reported since the scheduler is now free to schedule other pods to run.
186
+
The two metrics are called `kube_pod_resource_request` and `kube_pod_resource_limit`.
151
187
152
-
The metrics are exposed at the HTTP endpoint `/metrics/resources` and require the same authorization as the `/metrics`
153
-
endpoint on the scheduler. You must use the `--show-hidden-metrics-for-version=1.20` flag to expose these alpha stability metrics.
188
+
The metrics are exposed at the HTTP endpoint `/metrics/resources` and require the same
189
+
authorization as the `/metrics` endpoint on the scheduler. You must use the
190
+
`--show-hidden-metrics-for-version=1.20` flag to expose these alpha stability metrics.
154
191
155
192
## Disabling metrics
156
193
157
-
You can explicitly turn off metrics via command line flag `--disabled-metrics`. This may be desired if, for example, a metric is causing a performance problem. The input is a list of disabled metrics (i.e. `--disabled-metrics=metric1,metric2`).
194
+
You can explicitly turn off metrics via command line flag `--disabled-metrics`. This may be
195
+
desired if, for example, a metric is causing a performance problem. The input is a list of
Metrics with unbounded dimensions could cause memory issues in the components they instrument. To limit resource use, you can use the `--allow-label-value` command line option to dynamically configure an allow-list of label values for a metric.
200
+
Metrics with unbounded dimensions could cause memory issues in the components they instrument. To
201
+
limit resource use, you can use the `--allow-label-value` command line option to dynamically
202
+
configure an allow-list of label values for a metric.
162
203
163
204
In alpha stage, the flag can only take in a series of mappings as metric label allow-list.
164
205
Each mapping is of the format `<metric_name>,<label_name>=<allowed_labels>` where
165
206
`<allowed_labels>` is a comma-separated list of acceptable label names.
* Read about the [Prometheus text format](https://github.com/prometheus/docs/blob/master/content/docs/instrumenting/exposition_formats.md#text-based-format) for metrics
222
+
* Read about the [Prometheus text format](https://github.com/prometheus/docs/blob/master/content/docs/instrumenting/exposition_formats.md#text-based-format)
223
+
for metrics
177
224
* See the list of [stable Kubernetes metrics](https://github.com/kubernetes/kubernetes/blob/master/test/instrumentation/testdata/stable-metrics-list.yaml)
178
225
* Read about the [Kubernetes deprecation policy](/docs/reference/using-api/deprecation-policy/#deprecating-a-feature-or-behavior)
0 commit comments