Skip to content

Commit 253fe18

Browse files
authored
Merge pull request #38103 from my-git9/zhsync/system-metrics
[zh-cn]sync cluster-administration/system-metrics.md
2 parents 43a8d5d + 082d5e0 commit 253fe18

File tree

1 file changed

+87
-39
lines changed

1 file changed

+87
-39
lines changed

content/zh-cn/docs/concepts/cluster-administration/system-metrics.md

Lines changed: 87 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ weight: 70
1717
<!-- overview -->
1818

1919
<!--
20-
System component metrics can give a better look into what is happening inside them. Metrics are particularly useful for building dashboards and alerts.
20+
System component metrics can give a better look into what is happening inside them. Metrics are
21+
particularly useful for building dashboards and alerts.
2122
2223
Kubernetes components emit metrics in [Prometheus format](https://prometheus.io/docs/instrumenting/exposition_formats/).
2324
This format is structured plain text, designed so that people and machines can both read it.
@@ -33,11 +34,12 @@ Kubernetes 组件以 [Prometheus 格式](https://prometheus.io/docs/instrumentin
3334
<!--
3435
## Metrics in Kubernetes
3536
36-
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.
37+
In most cases metrics are available on `/metrics` endpoint of the HTTP server. For components that
38+
doesn't expose endpoint by default it can be enabled using `--bind-address` flag.
3739
3840
Examples of those components:
3941
-->
40-
## Kubernetes 中组件的指标
42+
## Kubernetes 中组件的指标 {#metrics-in-kubernetes}
4143

4244
在大多数情况下,可以通过 HTTP 访问组件的 `/metrics` 端点来获取组件的度量值。
4345
对于那些默认情况下不暴露端点的组件,可以使用 `--bind-address` 标志启用。
@@ -51,13 +53,17 @@ Examples of those components:
5153
* {{< glossary_tooltip term_id="kubelet" text="kubelet" >}}
5254

5355
<!--
54-
In a production environment you may want to configure [Prometheus Server](https://prometheus.io/) or some other metrics scraper
55-
to periodically gather these metrics and make them available in some kind of time series database.
56+
In a production environment you may want to configure [Prometheus Server](https://prometheus.io/)
57+
or some other metrics scraper to periodically gather these metrics and make them available in some
58+
kind of time series database.
5659
57-
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.
60+
Note that {{< glossary_tooltip term_id="kubelet" text="kubelet" >}} also exposes metrics in
61+
`/metrics/cadvisor`, `/metrics/resource` and `/metrics/probes` endpoints. Those metrics do not
62+
have same lifecycle.
5863
59-
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`.
60-
For example:
64+
If your cluster uses {{< glossary_tooltip term_id="rbac" text="RBAC" >}}, reading metrics requires
65+
authorization via a user, group or ServiceAccount with a ClusterRole that allows accessing
66+
`/metrics`. For example:
6167
-->
6268
在生产环境中,你可能需要配置 [Prometheus 服务器](https://prometheus.io/)
6369
某些其他指标搜集器以定期收集这些指标,并使它们在某种时间序列数据库中可用。
@@ -96,7 +102,7 @@ Stable metrics are guaranteed to not change. This means:
96102
Deprecated metrics are slated for deletion, but are still available for use.
97103
These metrics include an annotation about the version in which they became deprecated.
98104
-->
99-
## 指标生命周期
105+
## 指标生命周期 {#metric-lifecycle}
100106
101107
Alpha 指标 → 稳定的指标 → 弃用的指标 → 隐藏的指标 → 删除的指标
102108
@@ -137,7 +143,8 @@ For example:
137143
```
138144

139145
<!--
140-
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.
146+
Hidden metrics are no longer published for scraping, but are still available for use. To use a
147+
hidden metric, please refer to the [Show hidden metrics](#show-hidden-metrics) section.
141148
142149
Deleted metrics are no longer published and cannot be used.
143150
-->
@@ -149,13 +156,21 @@ Deleted metrics are no longer published and cannot be used.
149156
<!--
150157
## Show hidden metrics
151158
152-
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.
159+
As described above, admins can enable hidden metrics through a command-line flag on a specific
160+
binary. This intends to be used as an escape hatch for admins if they missed the migration of the
161+
metrics deprecated in the last release.
153162
154-
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.
163+
The flag `show-hidden-metrics-for-version` takes a version for which you want to show metrics
164+
deprecated in that release. The version is expressed as x.y, where x is the major version, y is
165+
the minor version. The patch version is not needed even though a metrics can be deprecated in a
166+
patch release, the reason for that is the metrics deprecation policy runs against the minor release.
155167
156-
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.
168+
The flag can only take the previous minor version as it's value. All metrics hidden in previous
169+
will be emitted if admins set the previous version to `show-hidden-metrics-for-version`. The too
170+
old version is not allowed because this violates the metrics deprecated policy.
157171
158-
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:
172+
Take metric `A` as an example, here assumed that `A` is deprecated in 1.n. According to metrics
173+
deprecated policy, we can reach the following conclusion:
159174
-->
160175
## 显示隐藏指标 {#show-hidden-metrics}
161176

@@ -174,10 +189,13 @@ Take metric `A` as an example, here assumed that `A` is deprecated in 1.n. Accor
174189

175190
<!--
176191
* In release `1.n`, the metric is deprecated, and it can be emitted by default.
177-
* 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`.
192+
* In release `1.n+1`, the metric is hidden by default and it can be emitted by command line
193+
`show-hidden-metrics-for-version=1.n`.
178194
* In release `1.n+2`, the metric should be removed from the codebase. No escape hatch anymore.
179195
180-
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`
196+
If you're upgrading from release `1.12` to `1.13`, but still depend on a metric `A` deprecated in
197+
`1.12`, you should set hidden metrics via command line: `--show-hidden-metrics=1.12` and remember
198+
to remove this metric dependency before upgrading to `1.14`
181199
-->
182200
* 在版本 `1.n` 中,这个指标已经弃用,且默认情况下可以生成。
183201
* 在版本 `1.n+1` 中,这个指标默认隐藏,可以通过命令行参数 `show-hidden-metrics-for-version=1.n` 来再度生成。
@@ -189,13 +207,20 @@ If you're upgrading from release `1.12` to `1.13`, but still depend on a metric
189207
<!--
190208
## Disable accelerator metrics
191209
192-
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.
210+
The kubelet collects accelerator metrics through cAdvisor. To collect these metrics, for
211+
accelerators like NVIDIA GPUs, kubelet held an open handle on the driver. This meant that in order
212+
to perform infrastructure changes (for example, updating the driver), a cluster administrator
213+
needed to stop the kubelet agent.
193214
194-
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).
215+
The responsibility for collecting accelerator metrics now belongs to the vendor rather than the
216+
kubelet. Vendors must provide a container that collects metrics and exposes them to the metrics
217+
service (for example, Prometheus).
195218
196-
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).
219+
The [`DisableAcceleratorUsageMetrics` feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
220+
disables metrics collected by the kubelet, with a
221+
[timeline for enabling this feature by default](https://github.com/kubernetes/enhancements/tree/411e51027db842355bd489691af897afc1a41a5e/keps/sig-node/1867-disable-accelerator-usage-metrics#graduation-criteria).
197222
-->
198-
## 禁用加速器指标
223+
## 禁用加速器指标 {#disable-accelerator-metrics}
199224

200225
kubelet 通过 cAdvisor 收集加速器指标。为了收集这些指标,对于 NVIDIA GPU 之类的加速器,
201226
kubelet 在驱动程序上保持打开状态。这意味着为了执行基础结构更改(例如更新驱动程序),
@@ -213,19 +238,20 @@ kubelet 在驱动程序上保持打开状态。这意味着为了执行基础结
213238
214239
### kube-controller-manager metrics
215240
216-
Controller manager metrics provide important insight into the performance and health of the controller manager.
217-
These metrics include common Go language runtime metrics such as go_routine count and controller specific metrics such as
218-
etcd request latencies or Cloudprovider (AWS, GCE, OpenStack) API latencies that can be used
219-
to gauge the health of a cluster.
241+
Controller manager metrics provide important insight into the performance and health of the
242+
controller manager. These metrics include common Go language runtime metrics such as go_routine
243+
count and controller specific metrics such as etcd request latencies or Cloudprovider (AWS, GCE,
244+
OpenStack) API latencies that can be used to gauge the health of a cluster.
220245
221-
Starting from Kubernetes 1.7, detailed Cloudprovider metrics are available for storage operations for GCE, AWS, Vsphere and OpenStack.
246+
Starting from Kubernetes 1.7, detailed Cloudprovider metrics are available for storage operations
247+
for GCE, AWS, Vsphere and OpenStack.
222248
These metrics can be used to monitor health of persistent volume operations.
223249
224250
For example, for GCE these metrics are called:
225251
-->
226-
## 组件指标
252+
## 组件指标 {#component-metrics}
227253

228-
### kube-controller-manager 指标
254+
### kube-controller-manager 指标 {#kube-controller-manager-metrics}
229255

230256
控制器管理器指标可提供有关控制器管理器性能和运行状况的重要洞察。
231257
这些指标包括通用的 Go 语言运行时指标(例如 go_routine 数量)和控制器特定的度量指标,
@@ -253,15 +279,20 @@ cloudprovider_gce_api_request_duration_seconds { request = "list_disk"}
253279
{{< feature-state for_k8s_version="v1.21" state="beta" >}}
254280

255281
<!--
256-
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.
282+
The scheduler exposes optional metrics that reports the requested resources and the desired limits
283+
of all running pods. These metrics can be used to build capacity planning dashboards, assess
284+
current or historical scheduling limits, quickly identify workloads that cannot schedule due to
285+
lack of resources, and compare actual usage to the pod's request.
257286
-->
258287
调度器会暴露一些可选的指标,报告所有运行中 Pods 所请求的资源和期望的约束值。
259288
这些指标可用来构造容量规划监控面板、访问调度约束的当前或历史数据、
260289
快速发现因为缺少资源而无法被调度的负载,或者将 Pod 的实际资源用量
261290
与其请求值进行比较。
262291

263292
<!--
264-
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:
293+
The kube-scheduler identifies the resource [requests and limits](/docs/concepts/configuration/manage-resources-containers/)
294+
configured for each Pod; when either a request or limit is non-zero, the kube-scheduler reports a
295+
metrics timeseries. The time series is labelled by:
265296
- namespace
266297
- pod name
267298
- the node where the pod is scheduled or an empty string if not yet scheduled
@@ -283,10 +314,14 @@ kube-scheduler 组件能够辩识各个 Pod 所配置的资源
283314
- 资源的单位,如果知道的话(例如,`cores`
284315

285316
<!--
286-
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`.
287-
288-
The metrics are exposed at the HTTP endpoint `/metrics/resources` and require the same authorization as the `/metrics`
289-
endpoint on the scheduler. You must use the `-show-hidden-metrics-for-version=1.20` flag to expose these alpha stability metrics.
317+
Once a pod reaches completion (has a `restartPolicy` of `Never` or `OnFailure` and is in the
318+
`Succeeded` or `Failed` pod phase, or has been deleted and all containers have a terminated state)
319+
the series is no longer reported since the scheduler is now free to schedule other pods to run.
320+
The two metrics are called `kube_pod_resource_request` and `kube_pod_resource_limit`.
321+
322+
The metrics are exposed at the HTTP endpoint `/metrics/resources` and require the same
323+
authorization as the `/metrics` endpoint on the scheduler. You must use the
324+
`-show-hidden-metrics-for-version=1.20` flag to expose these alpha stability metrics.
290325
-->
291326
一旦 Pod 进入完成状态(其 `restartPolicy``Never``OnFailure`,且
292327
其处于 `Succeeded``Failed` Pod 阶段,或者已经被删除且所有容器都具有
@@ -301,7 +336,9 @@ endpoint on the scheduler. You must use the `-show-hidden-metrics-for-version=1.
301336
<!--
302337
## Disabling metrics
303338
304-
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`).
339+
You can explicitly turn off metrics via command line flag `--disabled-metrics`. This may be
340+
desired if, for example, a metric is causing a performance problem. The input is a list of
341+
disabled metrics (i.e. `--disabled-metrics=metric1,metric2`).
305342
-->
306343
## 禁用指标 {#disabling-metrics}
307344

@@ -312,7 +349,9 @@ You can explicitly turn off metrics via command line flag `--disabled-metrics`.
312349
<!--
313350
## Metric cardinality enforcement
314351
315-
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.
352+
Metrics with unbounded dimensions could cause memory issues in the components they instrument. To
353+
limit resource use, you can use the `--allow-label-value` command line option to dynamically
354+
configure an allow-list of label values for a metric.
316355
-->
317356
## 指标顺序性保证 {#metric-cardinality-enforcement}
318357

@@ -322,22 +361,31 @@ Metrics with unbounded dimensions could cause memory issues in the components th
322361

323362
<!--
324363
The overall format looks like:
325-
`--allow-label-value <metric_name>,<label_name>='<allow_value1>, <allow_value2>...', <metric_name2>,<label_name>='<allow_value1>, <allow_value2>...', ...`.
364+
365+
```
366+
--allow-label-value <metric_name>,<label_name>='<allow_value1>, <allow_value2>...', <metric_name2>,<label_name>='<allow_value1>, <allow_value2>...', ...
367+
```
326368
-->
327369
最终的格式看起来会是这样:
328-
`--allow-label-value <指标名称>,<标签名称>='<可用值1>,<可用值2>...', <指标名称2>,<标签名称>='<可用值1>, <可用值2>...', ...`.
370+
371+
```
372+
--allow-label-value <指标名称>,<标签名称>='<可用值1>,<可用值2>...', <指标名称2>,<标签名称>='<可用值1>, <可用值2>...', ...
373+
```
329374

330375
<!--
331376
Here is an example:
332377
-->
333378
下面是一个例子:
334379

335-
`--allow-label-value number_count_metric,odd_number='1,3,5', number_count_metric,even_number='2,4,6', date_gauge_metric,weekend='Saturday,Sunday'`
380+
```none
381+
--allow-label-value number_count_metric,odd_number='1,3,5', number_count_metric,even_number='2,4,6', date_gauge_metric,weekend='Saturday,Sunday'
382+
```
336383

337384
## {{% heading "whatsnext" %}}
338385

339386
<!--
340-
* Read about the [Prometheus text format](https://github.com/prometheus/docs/blob/master/content/docs/instrumenting/exposition_formats.md#text-based-format) for metrics
387+
* Read about the [Prometheus text format](https://github.com/prometheus/docs/blob/master/content/docs/instrumenting/exposition_formats.md#text-based-format)
388+
for metrics
341389
* Read about the [Kubernetes deprecation policy](/docs/reference/using-api/deprecation-policy/#deprecating-a-feature-or-behavior)
342390
-->
343391
* 阅读有关指标的 [Prometheus 文本格式](https://github.com/prometheus/docs/blob/master/content/docs/instrumenting/exposition_formats.md#text-based-format)

0 commit comments

Comments
 (0)