# 为指标生成参考文档

LLMS index: [llms.txt](/llms.txt)

---

<!--
title: Generating reference documentation for metrics
content_type: task
weight: 100
-->

<!-- overview -->

<!--
This page demonstrates the generation of metrics reference documentation.
-->
本页演示如何生成指标参考文档。

## 准备开始


	<!--
### Requirements:

- You need a machine that is running Linux or macOS. On Windows, use
  [Windows Subsystem for Linux (WSL)](https://learn.microsoft.com/en-us/windows/wsl/install),
  since the build tooling relies on `make` and Bash scripts.
-->
<h3 id="requirements">需求<a class="td-heading-self-link" href="#requirements" aria-label="Heading self-link"></a></h3>
<ul>
<li>你需要一台 Linux 或 macOS 机器。在 Windows 上，
请使用<a href="https://learn.microsoft.com/en-us/windows/wsl/install">适用于 Linux 的 Windows 子系统（WS）</a>，
因为构建工具依赖于 <code>make</code> 和 Bash 脚本。</li>
</ul>
<!--
- You need to have these tools installed:

  - [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
  - [Go](https://go.dev/dl/), any recent release (Go downloads the exact toolchain a generator needs automatically)
  - [make](https://www.gnu.org/software/make/)
  - [gcc compiler/linker](https://gcc.gnu.org/)
  - [Docker](https://docs.docker.com/engine/installation/) (required only for the local website preview with `make container-serve`)
-->
<ul>
<li>
<p>你需要安装以下工具：</p>
<ul>
<li><a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">Git</a></li>
<li><a href="https://go.dev/dl/">Go</a>，任意近期版本（Go 会自动下载生成器所需的特定工具链）</li>
<li><a href="https://www.gnu.org/software/make/">make</a></li>
<li><a href="https://gcc.gnu.org/">gcc compiler/linker</a></li>
<li><a href="https://docs.docker.com/engine/installation/">Docker</a> （仅在使用 <code>make container-serve</code> 进行本地网站预览时需要）</li>
</ul>
</li>
</ul>
<!--
- You need to know how to create a pull request to a GitHub repository.
  This involves creating your own fork of the repository. For more
  information, see [Work from a local clone](/docs/contribute/new-content/open-a-pr/#fork-the-repo).
-->
<ul>
<li>你需要知道如何为一个 GitHub 仓库创建拉取请求（PR）。
这牵涉到创建仓库的派生（fork）副本。
有关信息可进一步查看<a href="/zh-cn/docs/contribute/new-content/open-a-pr/#fork-the-repo">基于本地副本开展工作</a>。</li>
</ul>


<!-- steps -->

<!--
## Clone the Kubernetes repository

The metric generation happens in the Kubernetes repository.
To clone the repository, change directories to where you want the clone to exist.

Then, execute the following command:
-->
## 克隆 Kubernetes 仓库   {#cloning-the-kubernetes-repository}

指标的生成发生在 Kubernetes 仓库中。
要克隆此仓库，请将目录更改为你要克隆到的目标位置。

然后，执行以下命令：

```shell
git clone https://www.github.com/kubernetes/kubernetes 
```

<!--
This creates a `kubernetes` folder in your current working directory.
-->
这将在当前工作目录中创建一个 `kubernetes` 文件夹。

<!--
## Generate the metrics

Inside the cloned Kubernetes repository, locate the
`test/instrumentation/documentation` directory.
The metrics documentation is generated in this directory.
-->
## 生成指标  {#generate-the-metrics}

在克隆的 Kubernetes 仓库中，找到 `test/instrumentation/documentation` 目录。
指标文档将在此目录中生成。

<!--
With each release, new metrics are added.
After you run the metrics documentation generator script, copy the
metrics documentation to the Kubernetes website and
publish the updated metrics documentation.

To generate the latest metrics, make sure you are in the root of the cloned Kubernetes directory.
Then, execute the following command:
-->
每次发布都会添加新的指标。你在运行指标文档生成脚本之后，
将指标文档复制到 Kubernetes 网站并发布更新的指标文档。

要生成最新的指标，请确保你位于已克隆的 Kubernetes 仓库的根目录中。
然后，执行以下命令：

```shell
./test/instrumentation/update-documentation.sh
```

<!--
To check for changes, execute:
-->
要检查变更，执行以下命令：

```shell
git status
```

<!--
The output is similar to:
-->
输出类似于：

```
./test/instrumentation/documentation/documentation.md
./test/instrumentation/documentation/documentation-list.yaml
```

<!--
## Copy the generated metrics documentation file to the Kubernetes website repository

1. Set the Kubernetes website root environment variable.

   Execute the following command to set the website root:
-->
## 将生成的指标文档文件复制到 Kubernetes 网站仓库   {#copy-the-generated-metrics-documentation-file-to-the-kubernetes-website-repository}

1. 设置 Kubernetes 网站根环境变量

   执行以下命令设置网站根目录：

   ```shell
   export WEBSITE_ROOT=<path to website root>
   ```

<!--
2. Copy the generated metrics file to the Kubernetes website repository.
-->
2. 将生成的指标文件复制到 Kubernetes 网站仓库。

   ```shell
   cp ./test/instrumentation/documentation/documentation.md "${WEBSITE_ROOT}/content/en/docs/reference/instrumentation/metrics.md"
   ```

   
<div class="alert alert-info" role="note"><h4 class="alert-heading">说明：</h4><!--
   If you get an error, check that you have permission to copy the file.
   You can use `chown` to change the file ownership back to your own user.
   -->
<p>如果出现错误，请检查你是否有权限复制文件。
你可以使用 <code>chown</code> 命令将文件所有权更改回你自己的用户。</p></div>


<!--
## Create a pull request

To create a pull request, follow the instructions in [Opening a pull request](/docs/contribute/new-content/open-a-pr/).
-->
## 创建 PR   {#creating-a-pull-request}

要创建 PR，请按照[提 PR](/zh-cn/docs/contribute/new-content/open-a-pr/) 中的说明操作。

## 接下来

<!--
* [Contribute-upstream](/docs/contribute/generate-ref-docs/contribute-upstream/)
* [Generating Reference Docs for Kubernetes Components and Tools](/docs/contribute/generate-ref-docs/kubernetes-components/)
* [Generating Reference Documentation for kubectl Commands](/docs/contribute/generate-ref-docs/kubectl/)
-->
* [贡献上游](/zh-cn/docs/contribute/generate-ref-docs/contribute-upstream/)
* [为 Kubernetes 组件和工具生成参考文档](/zh-cn/docs/contribute/generate-ref-docs/kubernetes-components/)
* [为 kubectl 命令生成参考文档](/zh-cn/docs/contribute/generate-ref-docs/kubectl/)
