Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

ClickHouse 10 min read How-to mediumAdept

Essential Monitoring Queries - part 1 - INSERT Queries

ClickHouse system tables such as part_log, query_log, asynchronous_insert_log, asynchronous_metric_log and parts can be queried with SQL to monitor and troubleshoot INSERT workloads. Ready-to-use queries cover new part creation rate, bulk insert counts versus rows written, insert duration percentiles, per-insert memory and CPU, MaxPartCountForPartition, parts per partition, and part-level errors. Comparing insert request counts to rows written, or watching part counts climb, gives early warning of small-insert patterns and high-cardinality partition keys that lead to 'Too many parts' errors. Duration and resource metrics are only accurate for synchronous inserts, not async_insert or the Buffer engine, and alerting on these queries through tools like Grafana is recommended.

Related posts

  • Monitoring Asynchronous Inserts

    ClickHouse mediumAdept

    ClickHouse asynchronous inserts can be monitored with SQL over system tables (query_log, asynchronous_insert_log, part_log, parts, and the PendingAsyncInsert metric), packaged as parameterized views for part creations, buffer flushes, flush errors and pending flushes. The flush-error view matters most in fire-and-forget mode, where failed buffer flushes are never reported back to the client. Worked scenarios show how flush and part frequency diverge from the configured threshold. Each node keeps a separate buffer per insert query shape and per settings set, and a partitioned table gets at least one part per partition key value in each flush.

  • Common issues you can solve using advanced monitoring dashboards

    ClickHouse mediumAdept

    ClickHouse ships a built-in Advanced Dashboard at /dashboard that charts query, MergeTree, OS and S3/cache metrics. Its panels are SQL queries over system.metric_log and system.asynchronous_metric_log. Setup means enabling those logs on self-hosted servers and creating a dashboard user with SELECT on the system tables plus REMOTE and CREATE TEMPORARY TABLE grants. Custom charts can be persisted in a separate dashboards table and merged with the defaults. Example diagnoses: unbatched inserts show as Max Parts for Partition spiking while Inserted Rows/sec stays low, and a Selected Rows/sec spike traced through system.query_log reveals a poor primary key (151M vs 6M rows read for the same query).

  • Asynchronous Data Inserts in ClickHouse

    ClickHouse mediumAdept

    ClickHouse asynchronous inserts move batching from the client to the server. Insert data goes into in-memory buffers, one per query shape and settings on each node, and is flushed as larger parts, which avoids the 'Too many parts' error that frequent small synchronous inserts trigger. In a benchmark with a serverless uptime-monitoring app (UpClick), 200 cloud functions inserting every 10 seconds pushed a 3-node ClickHouse Cloud service to the 300-active-part limit within 5 minutes using synchronous inserts. The post then covers buffer flush semantics, deduplication for idempotent retries, errors that only surface at flush time, how asynchronous inserts compare to Buffer tables, and how to tune return behavior and flush settings.

  • Essential Monitoring Queries - part 2 - SELECT Queries

    ClickHouse mediumAdept

    A set of SQL queries against ClickHouse system tables (system.parts, system.query_log, system.processes, system.stack_trace) for monitoring and troubleshooting SELECT workloads: cluster size overview, most expensive queries, ProfileEvents diffs between two query versions, hourly duration trends, per-client query counts, and diagnosing TOO_MANY_SIMULTANEOUS_QUERIES. Setting send_logs_level = 'trace' in clickhouse-client exposes per-query execution logs; in the UK price paid example, adding a projection ordered by town and price cut marks read from 3401 to 266 and latency from 1.2s to 0.028s. Queries use clusterAllReplicas for ClickHouse Cloud and can be adapted for self-managed clusters.

  • System Tables and a Window into the Internals of ClickHouse

    ClickHouse mediumAdept

    ClickHouse system tables are read-only virtual tables in the system database that expose server state, settings, metrics, errors, parts and query history. Most live in memory, while log tables such as query_log, part_log and metric_log persist on MergeTree storage. A set of practical diagnostic queries shows how to use them: system.settings for non-default values, query_log with normalizedQueryHash and ProfileEvents for slow, memory-heavy and failed queries, system.errors for frequent error codes with traces, and part_log to confirm inserts are producing parts. These queries can serve as a starting toolkit for troubleshooting and understanding cluster usage.

The quest for software engineering knowledge.

Look:
Layout: