> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 监控

> 您可以监控硬件资源的利用率以及 ClickHouse 服务器指标。

> [!NOTE]
>
> 本指南概述的监控数据可在 ClickHouse Cloud 中查看。除了可通过下文介绍的内置仪表板查看外，基础和高级性能指标也可以直接在主服务控制台中查看。

您可以监控：

* 硬件资源利用率。
* ClickHouse server 指标。

## 内置高级可观测性仪表板

![原生高级可观测性仪表板](https://mintcdn.com/private-7c7dfe99/nYSl14_LxtbSRLxz/images/cloud/manage/monitoring/native_advanced_dashboard.webp?fit=max\&auto=format\&n=nYSl14_LxtbSRLxz\&q=85\&s=38edf643d858dbc9d2c666025a1b104d)

ClickHouse 内置了高级可观测性仪表板，可通过 `$HOST:$PORT/dashboard` 访问 (需要用户名和密码) ，显示以下指标：

* 查询数/秒
* CPU 使用量 (核)
* 正在运行的查询
* 正在进行的合并
* 选取字节数/秒
* IO 等待
* CPU 等待
* 操作系统 CPU 使用量 (用户态)
* 操作系统 CPU 使用量 (内核态)
* 从磁盘读取
* 从文件系统读取
* 内存 (已跟踪)
* 插入行数/秒
* MergeTree parts 总数
* 分区中的最大 parts 数

## 资源利用率

ClickHouse 还会自行监控硬件资源的状态，例如：

* 处理器的负载和温度。
* 存储系统、RAM 和网络的利用率。

这些数据会被收集到 `system.asynchronous_metric_log` 表中。

## ClickHouse 服务器指标

ClickHouse server 内置了用于监控自身状态的能力。

要跟踪服务器事件，请使用服务器日志。请参阅配置文件中的 [logger](https://clickhouse.com/docs/zh/reference/settings/server-settings/settings/other.md#logger) 部分。

ClickHouse 收集：

* 反映服务器计算资源使用情况的各类指标。
* 查询处理的常见统计信息。

你可以在 [system.metrics](https://clickhouse.com/docs/zh/reference/system-tables/metrics.md)、[system.events](https://clickhouse.com/docs/zh/reference/system-tables/events.md) 和 [system.asynchronous\_metrics](https://clickhouse.com/docs/zh/reference/system-tables/asynchronous_metrics.md) 表中找到这些指标。

你可以将 ClickHouse 配置为将指标导出到 [Graphite](https://github.com/graphite-project)。请参阅 ClickHouse server 配置文件中的 [Graphite 部分](https://clickhouse.com/docs/zh/reference/settings/server-settings/settings/graphite.md#graphite)。在配置指标导出之前，你应按照其官方[指南](https://graphite.readthedocs.io/en/latest/install.html)先完成 Graphite 的设置。

你可以将 ClickHouse 配置为将指标导出到 [Prometheus](https://prometheus.io)。请参阅 ClickHouse server 配置文件中的 [Prometheus 部分](https://clickhouse.com/docs/zh/reference/settings/server-settings/settings/other.md#prometheus)。在配置指标导出之前，你应按照其官方[指南](https://prometheus.io/docs/prometheus/latest/installation/)先完成 Prometheus 的设置。

此外，你还可以通过 HTTP API 监控服务器可用性。向 `/ping` 发送 `HTTP GET` 请求。如果服务器可用，它会返回 `200 OK`。

要监控集群配置中的服务器，你应设置 [max\_replica\_delay\_for\_distributed\_queries](https://clickhouse.com/docs/zh/reference/settings/session-settings/max.md#max_replica_delay_for_distributed_queries) 参数，并使用 HTTP 资源 `/replicas_status`。当副本可用且未落后于其他副本时，对 `/replicas_status` 的请求会返回 `200 OK`。如果副本存在延迟，则会返回 `503 HTTP_SERVICE_UNAVAILABLE`，并附带有关延迟差距的信息。
