Merge pull request #45651 from windsonsea/metricy
[zh] Add translations to kube-state-metrics.md
This commit is contained in:
commit
2e1bc38df5
|
@ -0,0 +1,79 @@
|
|||
---
|
||||
title: Kubernetes 对象状态的指标
|
||||
content_type: concept
|
||||
weight: 75
|
||||
description: >-
|
||||
kube-state-metrics,一个生成和公开集群层面指标的插件代理。
|
||||
---
|
||||
<!--
|
||||
title: Metrics for Kubernetes Object States
|
||||
content_type: concept
|
||||
weight: 75
|
||||
description: >-
|
||||
kube-state-metrics, an add-on agent to generate and expose cluster-level metrics.
|
||||
-->
|
||||
|
||||
<!--
|
||||
The state of Kubernetes objects in the Kubernetes API can be exposed as metrics.
|
||||
An add-on agent called [kube-state-metrics](https://github.com/kubernetes/kube-state-metrics) can connect to the Kubernetes API server and expose a HTTP endpoint with metrics generated from the state of individual objects in the cluster.
|
||||
It exposes various information about the state of objects like labels and annotations, startup and termination times, status or the phase the object currently is in.
|
||||
For example, containers running in pods create a `kube_pod_container_info` metric.
|
||||
This includes the name of the container, the name of the pod it is part of, the {{< glossary_tooltip text="namespace" term_id="namespace" >}} the pod is running in, the name of the container image, the ID of the image, the image name from the spec of the container, the ID of the running container and the ID of the pod as labels.
|
||||
-->
|
||||
Kubernetes API 中 Kubernetes 对象的状态可以被公开为指标。
|
||||
一个名为 [kube-state-metrics](https://github.com/kubernetes/kube-state-metrics)
|
||||
的插件代理可以连接到 Kubernetes API 服务器并公开一个 HTTP 端点,提供集群中各个对象的状态所生成的指标。
|
||||
此代理公开了关于对象状态的各种信息,如标签和注解、启动和终止时间、对象当前所处的状态或阶段。
|
||||
例如,针对运行在 Pod 中的容器会创建一个 `kube_pod_container_info` 指标。
|
||||
其中包括容器的名称、所属的 Pod 的名称、Pod 所在的{{< glossary_tooltip text="命名空间" term_id="namespace" >}}、
|
||||
容器镜像的名称、镜像的 ID、容器规约中的镜像名称、运行中容器的 ID 和用作标签的 Pod ID。
|
||||
|
||||
{{% thirdparty-content single="true" %}}
|
||||
|
||||
<!--
|
||||
An external component that is able and capable to scrape the endpoint of kube-state-metrics (for example via Prometheus) can now be used to enable the following use cases.
|
||||
-->
|
||||
有能力(例如通过 Prometheus)抓取 kube-state-metrics 端点的外部组件现在可用于实现以下使用场景。
|
||||
|
||||
<!--
|
||||
## Example: using metrics from kube-state-metrics to query the cluster state {#example-kube-state-metrics-query-1}
|
||||
|
||||
Metric series generated by kube-state-metrics are helpful to gather further insights into the cluster, as they can be used for querying.
|
||||
|
||||
If you use Prometheus or another tool that uses the same query language, the following PromQL query returns the number of pods that are not ready:
|
||||
-->
|
||||
## 示例:使用来自 kube-state-metrics 的指标查询集群状态 {#example-kube-state-metrics-query-1}
|
||||
|
||||
通过 kube-state-metrics 生成的系列指标有助于进一步洞察集群,因为这些指标可用于查询。
|
||||
|
||||
如果你使用 Prometheus 或其他采用相同查询语言的工具,则以下 PromQL 查询将返回未就绪的 Pod 数:
|
||||
|
||||
```
|
||||
count(kube_pod_status_ready{condition="false"}) by (namespace, pod)
|
||||
```
|
||||
|
||||
<!--
|
||||
## Example: alerting based on from kube-state-metrics {#example-kube-state-metrics-alert-1}
|
||||
|
||||
Metrics generated from kube-state-metrics also allow for alerting on issues in the cluster.
|
||||
|
||||
If you use Prometheus or a similar tool that uses the same alert rule language, the following alert will fire if there are pods that have been in a `Terminating` state for more than 5 minutes:
|
||||
-->
|
||||
## 示例:基于 kube-state-metrics 发出警报 {#example-kube-state-metrics-alert-1}
|
||||
|
||||
kube-state-metrics 生成的指标还允许在集群中出现问题时发出警报。
|
||||
|
||||
如果你使用 Prometheus 或类似采用相同警报规则语言的工具,若有某些 Pod 处于 `Terminating` 状态超过 5 分钟,将触发以下警报:
|
||||
|
||||
```yaml
|
||||
groups:
|
||||
- name: Pod state
|
||||
rules:
|
||||
- alert: PodsBlockedInTerminatingState
|
||||
expr: count(kube_pod_deletion_timestamp) by (namespace, pod) * count(kube_pod_status_reason{reason="NodeLost"} == 0) by (namespace, pod) > 0
|
||||
for: 5m
|
||||
labels:
|
||||
severity: page
|
||||
annotations:
|
||||
summary: Pod {{$labels.namespace}}/{{$labels.pod}} blocked in Terminating state.
|
||||
```
|
Loading…
Reference in New Issue