> For the complete documentation index, see [llms.txt](https://docs.groundcover.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.groundcover.com/collect-data/data-sources/clickhouse-database-monitoring/clickhouse-health-metrics.md).

# ClickHouse Health Metrics Reference

Exported ClickHouse health metrics, grouped by source, with types, labels, and interpretation.

Use this reference with [ClickHouse Database Monitoring](https://docs.groundcover.com/collect-data/data-sources/clickhouse-database-monitoring.md) for prerequisites, permissions, configuration, and troubleshooting.

Every suffix below is prefixed with `groundcover_db_ch_`. For example, `connections` is exported as `groundcover_db_ch_connections`. Metrics include `server_address`, `server_port`, integration labels such as `gc_integration_name`, and configured extra labels. Group-specific labels are described below; avoid extra labels that overwrite these dimensions.

Counters are raw cumulative database counters: use `rate()` or `increase()` to measure activity over time and handle resets. Gauges describe the current observation. A missing series can mean a disabled group, missing capability/permission, filtering, top-N selection, or an empty source. It does not imply zero. See [collection diagnostics](https://docs.groundcover.com/collect-data/monitor-data-sources-integrations.md#database-monitoring-diagnostics).

In cluster mode, health queries use `cluster()` (one replica per shard) and add `shard_number`, a zero-based shard label. These metrics are not an exhaustive per-replica inventory. Statement measurements have a separate all-replica collection path.

## Parts

system.parts; active parts only. Labels: db\_namespace and db\_collection\_name. Top tables are ranked by active part count.

| Metric suffix           | Type / unit        | Meaning and additional labels                                                                                |
| ----------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------ |
| `parts_active`          | Gauge; parts       | Active part count.                                                                                           |
| `parts_level0`          | Gauge; parts       | Active parts with merge level zero.                                                                          |
| `parts_by_type`         | Gauge; parts       | Active Compact or Wide parts. `part_type`: `compact`, `wide`.                                                |
| `parts_bytes`           | Gauge; bytes       | On-disk, compressed, or uncompressed bytes of active parts. `kind`: `on_disk`, `compressed`, `uncompressed`. |
| `parts_rows`            | Gauge; rows        | Rows in active parts.                                                                                        |
| `parts_merge_level_max` | Gauge; merge level | Highest merge level among active parts.                                                                      |

## Merges

system.merges; labels: db\_namespace and db\_collection\_name. Empty when no merges run.

| Metric suffix                   | Type / unit    | Meaning and additional labels                        |
| ------------------------------- | -------------- | ---------------------------------------------------- |
| `merges_running`                | Gauge; merges  | Currently running merges for the table.              |
| `merge_longest_elapsed_seconds` | Gauge; seconds | Elapsed time of the longest running merge.           |
| `merge_min_progress`            | Gauge; ratio   | Lowest progress among running merges, as a fraction. |

## Mutations

system.mutations; labels: db\_namespace and db\_collection\_name. Completed mutations are excluded.

| Metric suffix       | Type / unit      | Meaning and additional labels                                                                              |
| ------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------- |
| `mutations_pending` | Gauge; mutations | Mutations whose is\_done value is 0.                                                                       |
| `mutations_failed`  | Gauge; mutations | Pending mutations with a nonempty latest\_fail\_reason; a current count, not a cumulative failure counter. |

## Replication

system.replicas; table series have db\_namespace and db\_collection\_name. readonly\_replicas is server/shard-wide and may be zero even when there are no replicated tables.

| Metric suffix               | Type / unit                  | Meaning and additional labels                                                                                                                       |
| --------------------------- | ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `replication_queue`         | Gauge; entries               | Replication queue entries.                                                                                                                          |
| `replication_queue_by_kind` | Gauge; entries               | Queued inserts or merges. `kind`: `insert`, `merge`.                                                                                                |
| `replica_delay_seconds`     | Gauge; seconds               | Absolute replication delay reported by the replica.                                                                                                 |
| `replica_log_delay`         | Gauge; log positions         | Nonnegative difference between log\_max\_index and log\_pointer.                                                                                    |
| `replica_future_parts`      | Gauge; parts                 | Parts that will result from in-progress work.                                                                                                       |
| `replica_parts_to_check`    | Gauge; parts                 | Parts queued for verification.                                                                                                                      |
| `replicas_active`           | Gauge; replicas              | Active replicas reported for the replicated table.                                                                                                  |
| `replicas_total`            | Gauge; replicas              | Total replicas reported for the replicated table.                                                                                                   |
| `readonly_replicas`         | Gauge; table-replica entries | Count of read-only entries in system.replicas, aggregated across tables on the queried server/shard. This is not a count of distinct cluster nodes. |

## Connections

system.metrics; interface is http, tcp, or interserver. Missing source counters produce no corresponding series.

| Metric suffix | Type / unit        | Meaning and additional labels     |
| ------------- | ------------------ | --------------------------------- |
| `connections` | Gauge; connections | Current connections by interface. |

## Capacity

system.asynchronous\_metrics, system.metrics, and system.disks. Labels: metric for selected values; disk and kind for capacity.

| Metric suffix  | Type / unit             | Meaning and additional labels                                                                                       |
| -------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `async_metric` | Gauge; source-dependent | Value identified by the metric label; units depend on that source metric. MemoryTracking comes from system.metrics. |
| `disk_bytes`   | Gauge; bytes            | Free or total space reported for a disk. `kind`: `free`, `total`.                                                   |

By default, `async_metric` has these `metric` label values:

| metric label               | Unit      | Meaning                                     |
| -------------------------- | --------- | ------------------------------------------- |
| `MemoryTracking`           | Bytes     | Current tracked memory from system.metrics. |
| `MaxPartCountForPartition` | Parts     | Maximum part count for a partition.         |
| `Uptime`                   | Seconds   | Server uptime.                              |
| `NumberOfDatabases`        | Databases | Database count.                             |
| `NumberOfTables`           | Tables    | Table count.                                |
| `MarkCacheBytes`           | Bytes     | Memory occupied by the mark cache.          |

Other label values depend on the configured include list and source metrics. See [Customizing included metrics](#customizing-included-metrics) to discover names and configure selection.

## Events

system.events; event identifies the cumulative counter.

| Metric suffix  | Type / unit               | Meaning and additional labels                                                                                                                           |
| -------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `events_total` | Counter; source-dependent | Cumulative event value identified by the event label. Default events are counts; explicitly included events can have other units defined by ClickHouse. |

Default `event` label values are `Query`, `FailedQuery`, `FailedSelectQuery`, `FailedInsertQuery`, `DelayedInserts`, `RejectedInserts`, `ReplicatedPartFailedFetches`, and `DistributedConnectionFailTry`. These represent query activity/failures, insert pressure, failed part fetches, and distributed connection failures. Additional events require an explicit include list or wildcard.

## Detached parts

system.detached\_parts; labels: db\_namespace, db\_collection\_name, and reason\_class. Empty when no detached parts exist.

| Metric suffix    | Type / unit  | Meaning and additional labels                                |
| ---------------- | ------------ | ------------------------------------------------------------ |
| `detached_parts` | Gauge; parts | Detached parts by reason class: corrupted, manual, or other. |

## Table sizes

system.tables; labels: db\_namespace and db\_collection\_name. Separate top-N queries rank by rows and bytes, so the selected tables can differ. NULL totals are omitted.

| Metric suffix | Type / unit  | Meaning and additional labels                           |
| ------------- | ------------ | ------------------------------------------------------- |
| `table_rows`  | Gauge; rows  | total\_rows reported by system.tables, when available.  |
| `table_bytes` | Gauge; bytes | total\_bytes reported by system.tables, when available. |

## View refreshes

system.view\_refreshes; requires status, last\_success\_time, and written\_rows columns. Labels include db\_namespace, db\_collection\_name, and status on the status series. Empty when no refreshable views exist.

| Metric suffix                           | Type / unit       | Meaning and additional labels                                                                   |
| --------------------------------------- | ----------------- | ----------------------------------------------------------------------------------------------- |
| `view_refresh_status`                   | Gauge; constant 1 | Constant 1 with the current status in a label; the numeric value is not a success/failure code. |
| `view_refresh_last_success_age_seconds` | Gauge; seconds    | Seconds since the last successful refresh; omitted if no timestamp is available.                |
| `view_refresh_written_rows`             | Gauge; rows       | Written rows reported by system.view\_refreshes; a gauge, not a cumulative counter.             |

## Dictionaries

system.dictionaries; labels: db\_namespace and dictionary. Empty when no dictionaries exist.

| Metric suffix             | Type / unit     | Meaning and additional labels                                           |
| ------------------------- | --------------- | ----------------------------------------------------------------------- |
| `dictionary_memory_bytes` | Gauge; bytes    | Bytes allocated by a dictionary.                                        |
| `dictionary_items`        | Gauge; elements | Dictionary element count.                                               |
| `dictionary_load`         | Gauge; ratio    | Dictionary load\_factor. This is a load factor, not a load-status code. |

## Customizing included metrics

Leave `include` unset for the default Capacity and Events selections above. Customize it only when you need additional metrics or a narrower selection. These are **ClickHouse source names**, with exact spelling and case, not exported `groundcover_db_ch_*` metric names.

| Configuration field                     | Supported names                                                                                                                                                              |
| --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `healthMetrics.groups.capacity.include` | Names in `system.asynchronous_metrics.metric`, plus the special `MemoryTracking` metric from `system.metrics`. Other `system.metrics` names are not selected by this option. |
| `healthMetrics.groups.events.include`   | Names in `system.events.event`.                                                                                                                                              |

Names depend on the monitored server's capabilities and configuration. Discover the available choices by running these read-only queries as the monitoring user on that server.

Capacity choices and current values:

```sql
SELECT name, value
FROM (
    SELECT metric AS name, value FROM system.asynchronous_metrics
    UNION ALL
    SELECT metric AS name, value FROM system.metrics WHERE metric = 'MemoryTracking'
)
ORDER BY name;
```

Event choices, values, and descriptions:

```sql
SELECT event, value, description
FROM system.events
ORDER BY event;
```

See ClickHouse's [asynchronous metric descriptions](https://clickhouse.com/docs/reference/system-tables/asynchronous_metrics) and [event descriptions](https://clickhouse.com/docs/reference/system-tables/events) for interpretation. The values returned by your server determine what can be selected there. In cluster mode, availability can differ between members; repeat the checks on relevant nodes. A name absent from a queried source produces no matching series; a misspelled name does not cause a configuration error.

| include value  | Behavior                                                                                                                                                                                |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Omitted        | Uses the defaults listed above.                                                                                                                                                         |
| Explicit names | Replaces the defaults. Include default names too if you want to retain them.                                                                                                            |
| `[]`           | Selects no named metrics/events. Capacity still collects disk metrics.                                                                                                                  |
| `["*"]`        | Selects all asynchronous metrics plus MemoryTracking for Capacity, or all events for Events, subject to collection result limits. This can substantially increase the number of series. |

Explicit lists are bounded to 100 entries and 16 KiB of names. Disk capacity is collected independently of the Capacity include list. Applied bounds and collection errors appear in the [collection diagnostics](https://docs.groundcover.com/collect-data/monitor-data-sources-integrations.md#database-monitoring-diagnostics).

For example, merge these group settings into the existing integration `config` to select only the named Capacity and Events values, while retaining disk collection:

```json
{
  "healthMetrics": {
    "enabled": true,
    "groups": {
      "capacity": {"enabled": true, "include": ["MemoryTracking", "MarkCacheBytes"]},
      "events": {"enabled": true, "include": ["Query", "FailedQuery"]}
    }
  }
}
```

Capacity values appear as `groundcover_db_ch_async_metric{metric="<name>"}`; events appear as `groundcover_db_ch_events_total{event="<name>"}`. Use `rate()` or `increase()` for cumulative events and check each event's unit before combining values.

## Query examples

Replace `<integration-name>` with the integration name. Choose a rate window spanning several scrapes.

Query event rate:

```promql
sum by (shard_number) (
  rate(groundcover_db_ch_events_total{gc_integration_name="<integration-name>", event="Query"}[5m])
)
```

Free disk space:

```promql
groundcover_db_ch_disk_bytes{gc_integration_name="<integration-name>", kind="free"}
```

Pending mutations with a recorded failure reason:

```promql
groundcover_db_ch_mutations_failed{gc_integration_name="<integration-name>"} > 0
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.groundcover.com/collect-data/data-sources/clickhouse-database-monitoring/clickhouse-health-metrics.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
