---
title: "Monitor SLAs and scale ClickHouse Cloud with clickhousectl and agents"
description: "ClickHouse Cloud can automatically scale infrastructure up and down, but teams may need to monitor latency SLAs for specific workloads such as a frontend dashboard requiring p99 under 200 ms. The guide tags queries with log_comment, reads system.query_log through clickhousectl, and aggregates query_duration_ms over a defined window to measure the SLA. When it is breached, operators compare query volume and latency with Prometheus-compatible CPU, memory, and concurrency metrics to distinguish increased concurrency from resource contention, then choose horizontal replica scaling or vertical replica sizing. A cron-based script can scale out when p99 exceeds a threshold, while an agent can inspect evidence and apply one scaling action using clickhousectl; actions are recorded in the ClickHouse Cloud activity log."
---

# Monitor SLAs and scale ClickHouse Cloud with clickhousectl and agents

[Clickhouse](https://yomu.fyi/company/clickhouse) · Jun 5, 2026

**Type:** Tutorial

## Summary

ClickHouse Cloud can automatically scale infrastructure up and down, but teams may need to monitor latency SLAs for specific workloads such as a frontend dashboard requiring p99 under 200 ms. The guide tags queries with log\_comment, reads system.query\_log through clickhousectl, and aggregates query\_duration\_ms over a defined window to measure the SLA. When it is breached, operators compare query volume and latency with Prometheus-compatible CPU, memory, and concurrency metrics to distinguish increased concurrency from resource contention, then choose horizontal replica scaling or vertical replica sizing. A cron-based script can scale out when p99 exceeds a threshold, while an agent can inspect evidence and apply one scaling action using clickhousectl; actions are recorded in the ClickHouse Cloud activity log.

## Context

Specific query SLAs, such as a frontend dashboard requiring p99 latency under 200 ms, may need monitoring beyond ClickHouse Cloud's automatic infrastructure scaling. An SLA breach shows that latency increased, but additional investigation is needed to determine whether query concurrency, competing workloads, CPU, memory, or other resource conditions are responsible.

## Approach / What changed

Tag tracked queries with log\_comment and measure their latency from system.query\_log using clickhousectl. Investigate breaches by comparing query volume and p99 latency with service metrics from the Prometheus-compatible endpoint, then scale horizontally with more replicas or vertically by changing replica memory according to the suspected cause. The workflow can run from cron or delegate investigation and remediation to an agent, with actions recorded in the activity log.

## Takeaways

- Use log\_comment to isolate a workload in system.query\_log and calculate its p99 query\_duration\_ms over a chosen time window.
- High concurrency with low memory points toward adding replicas, while memory near the limit on every replica suggests using larger replicas.
- The workflow supports both a simple cron-based threshold check and agent-driven investigation; clickhousectl actions appear in the ClickHouse Cloud activity log.

**Tags:** [Monitoring](https://yomu.fyi/topic/monitoring), [Observability](https://yomu.fyi/topic/observability), [Performance](https://yomu.fyi/topic/performance), [Scalability](https://yomu.fyi/topic/scalability)

- Source: [Clickhouse](https://clickhouse.com/blog/monitor-and-scale-clickhouse-cloud-with-clickhousectl)
- Source URL: https://clickhouse.com/blog/monitor-and-scale-clickhouse-cloud-with-clickhousectl
- Ingested by Yomu: 2026-08-29T01:34:26.204Z

[Read original post](https://clickhouse.com/blog/monitor-and-scale-clickhouse-cloud-with-clickhousectl)
