> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 指标参考

> Managed Postgres Prometheus 端点提供的完整指标列表

export const galaxyOnClick = eventName => () => {
  try {
    if (typeof window !== "undefined" && window.galaxy && eventName) {
      window.galaxy.track(eventName, {
        interaction: "click"
      });
    }
  } catch (e) {}
};

export const BetaBadge = ({link, galaxyTrack, galaxyEvent}) => {
  if (link) {
    return <a href={link} target="_blank" rel="noopener noreferrer" className="betaBadge" onClick={galaxyTrack && galaxyEvent ? galaxyOnClick(galaxyEvent) : undefined}>
                <Icon />
                <span>Beta</span>
            </a>;
  }
  return <div className="betaBadge">
            <Icon />
            <span>
                Beta feature. 
                <u>
                    <a href="/docs/beta-and-experimental-features#beta-features">
                        Learn more.
                    </a>
                </u>
            </span>
        </div>;
};

本页列出了
[Managed Postgres Prometheus 端点](/zh/products/managed-postgres/monitoring/prometheus)
公开的所有指标。
有关配置和身份验证，请参阅 [Prometheus 端点] 页面。

<div id="common-labels">
  ## 常见标记
</div>

每个指标都带有以下标记：

| 标记                      | 描述             |
| ----------------------- | -------------- |
| `clickhouse_org`        | 组织 ID          |
| `postgres_service`      | Postgres 服务 ID |
| `postgres_service_name` | Postgres 服务名称  |

有些指标还会添加一个标记，用于表示其细分维度 (例如 CPU 指标中的 `mode`、连接中的 `state`，以及数据库大小中的 `database`) 。这些都会在对应的各项指标中列出。

<div id="information-metric">
  ## 信息指标
</div>

`PostgresServiceInfo` 是一个值始终为 `1` 的 gauge 指标，并通过其标签携带
服务当前的状态和版本。可用它将状态关联到其他指标上，
或在服务离开 `running` 状态时触发告警。

| 指标                    | 类型    | 额外标签                                  | 说明                     |
| --------------------- | ----- | ------------------------------------- | ---------------------- |
| `PostgresServiceInfo` | gauge | `postgres_status`, `postgres_version` | 每个服务对应一条时间序列；值始终为 `1`。 |

`postgres_status` 用于报告服务当前的生命周期状态
(例如 `running`、`creating`、`stopped`) 。`postgres_version`
用于报告 Postgres 的主版本号 (例如 `17`、`18`) 。

<div id="capacity">
  ## 容量
</div>

为服务预配的静态资源上限。只有在
调整服务规格时，这些值才会发生变化。

| 指标                                 | 类型    | 单位    | 描述              |
| ---------------------------------- | ----- | ----- | --------------- |
| `PostgresServer_CPUCores`          | gauge | cores | 分配给服务的 CPU 核心数。 |
| `PostgresServer_MemoryLimitBytes`  | gauge | bytes | 分配给服务的内存。       |
| `PostgresServer_StorageLimitBytes` | gauge | bytes | 分配给服务的存储容量。     |

<div id="resource-utilization">
  ## 资源利用率
</div>

| 指标                                     | 类型    | 额外标签   | 描述                                                                                |
| -------------------------------------- | ----- | ------ | --------------------------------------------------------------------------------- |
| `PostgresServer_CPUSeconds_Total`      | 计数器   | `mode` | 已消耗的 CPU 时间，按模式细分：`user`、`system`、`iowait`、`softirq`、`steal`、`irq`、`nice`、`idle`。 |
| `PostgresServer_MemoryUsedPercent`     | gauge |        | 已用内存，占 `PostgresServer_MemoryLimitBytes` 的百分比。                                    |
| `PostgresServer_MemoryCachePercent`    | gauge |        | 缓存和缓冲区占用的内存，占总内存的百分比。                                                             |
| `PostgresServer_FilesystemUsedPercent` | gauge |        | 已用文件系统空间，占总存储空间的百分比。                                                              |

要将 CPU 用量计算为百分比，请计算
`PostgresServer_CPUSeconds_Total` 在你关注的各模式下的速率，并
除以 `PostgresServer_CPUCores`。

<div id="io">
  ## 磁盘与网络 I/O
</div>

| 指标                                          | 类型  | 单位    | 说明          |
| ------------------------------------------- | --- | ----- | ----------- |
| `PostgresServer_DiskReads_Total`            | 计数器 | ops   | 已完成的磁盘读操作。  |
| `PostgresServer_DiskWrites_Total`           | 计数器 | ops   | 已完成的磁盘写操作。  |
| `PostgresServer_NetworkReceiveBytes_Total`  | 计数器 | bytes | 通过网络接收的字节数。 |
| `PostgresServer_NetworkTransmitBytes_Total` | 计数器 | bytes | 通过网络发送的字节数。 |

<div id="database-activity">
  ## 数据库活动
</div>

自服务启动以来的累计计数器。使用 `rate()` 或 `irate()` 可将其
转换为每秒值。

| 指标                                            | 类型  | 描述       |
| --------------------------------------------- | --- | -------- |
| `PostgresServer_TuplesFetched_Total`          | 计数器 | 查询拉取的行数。 |
| `PostgresServer_TuplesInserted_Total`         | 计数器 | 已插入的行数。  |
| `PostgresServer_TuplesUpdated_Total`          | 计数器 | 已更新的行数。  |
| `PostgresServer_TuplesDeleted_Total`          | 计数器 | 已删除的行数。  |
| `PostgresServer_TransactionsCommitted_Total`  | 计数器 | 已提交的事务数。 |
| `PostgresServer_TransactionsRolledBack_Total` | 计数器 | 已回滚的事务数。 |
| `PostgresServer_Deadlocks_Total`              | 计数器 | 检测到的死锁数。 |

<div id="connections-cache-size">
  ## 连接、缓存和数据库大小
</div>

| 指标                                 | 类型    | 额外标签       | 描述                                                 |
| ---------------------------------- | ----- | ---------- | -------------------------------------------------- |
| `PostgresServer_ActiveConnections` | gauge | `state`    | 按状态划分的连接数 (例如 `active`、`idle`) 。                   |
| `PostgresServer_CacheHitRatio`     | gauge |            | 缓冲区缓存命中率：以百分比表示由缓存提供的块数占访问块总数的比例。                  |
| `PostgresServer_DatabaseSizeBytes` | gauge | `database` | 每个数据库的磁盘大小，单位为字节。包括默认的 `postgres` 数据库以及任何用户创建的数据库。 |

<div id="related">
  ## 相关页面
</div>

* [Prometheus 端点] — 配置、身份验证和抓取
* [仪表板](/zh/products/managed-postgres/monitoring/dashboard) — Cloud Console 内置图表
* [OpenAPI 指南](/zh/products/managed-postgres/openapi) — 创建 API key
  以及查询组织和服务 ID

[Prometheus 端点]: /products/managed-postgres/monitoring/prometheus
