Repository navigation
feat(chart): alert before the ClickHouse disk fills and stop inserts at 95% - #677
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the nudgebee-agent Helm chart to version 0.1.31. It adds a new template to render PrometheusRule alerts for ClickHouse, configures ClickHouse to stop inserts when free disk space falls below 5%, and introduces two new Prometheus alerts (ClickHouseDiskFilling and ClickHouseDiskAlmostFull) to monitor disk usage. There are no review comments, so I have no feedback to provide.
blue4209211
left a comment
There was a problem hiding this comment.
The insert guard looks good: min_free_disk_ratio_to_perform_insert = 0.05 with the two disk alerts in front of it. Gating the new PrometheusRule on the CRD (or enablePrometheusStack) keeps installs without the operator safe.
Two checks before merge, because these rules render for the first time on every cluster with the Prometheus operator:
ClickHouseHighLatency:clickhouse_query_duration_secondsisn't exported by ClickHouse's built-in Prometheus endpoint, so this rule can never fire. On your question, I'd drop it rather than ship a dead alert. A latency alert can come later from a metric ClickHouse does export.ClickHouseInstanceDown:up{job="clickhouse"}only fires if the scrape'sjoblabel really isclickhouse. It comes from this chart's ServiceMonitor, so check the rendered target'sjobwithhelm template, or match on the service label instead.
Minor:
- The disk expressions cover only the disk named
default(…_DiskAvailable_default). That's fine for the bundled setup; worth a values comment for custom storage policies. - At 95% full, logs held back upstream will wait, while traces and metrics are dropped after the exporter's retry window. That's worth one line in the chart docs next to the alert text.
- Follow-up idea: these alerts only reach clusters with Prometheus plus Alertmanager. Reporting ClickHouse disk usage on the runner's heartbeat would let the backend surface it everywhere.
…at 95%
Logs, traces and metrics share the ClickHouse volume, and its TTL drops
data by age, not size, so a noisy namespace can fill the disk and stop
every write with no warning.
- ClickHouseDiskFilling (over 80% for 10m, warning) and
ClickHouseDiskAlmostFull (over 90% for 5m, critical), from ClickHouse's
own DiskAvailable_<disk>/DiskTotal_<disk> metrics. label_replace moves
the disk name into a disk label, so every disk is covered.
- merge_tree min_free_disk_ratio_to_perform_insert = 0.05: inserts are
refused (NOT_ENOUGH_SPACE) while less than 5% is free, which leaves room
for merges, TTL part drops and queries instead of a full disk.
- templates/clickhouse-prometheusrule.yaml renders
clickhouse.metrics.prometheusRule.rules. The Bitnami subchart has no
PrometheusRule template, so those rules were never applied before. It
renders only when a ClickHouse ServiceMonitor does, and each expr goes
through tpl so it can match this release's scrape target.
- ClickHouseInstanceDown matched up{job="clickhouse"}, but the operator
sets job to the Service name (nudgebee-agent-clickhouse by default). It
now matches namespace and service of this release, and also fires when
the target is absent.
- ClickHouseHighLatency is removed: ClickHouse's Prometheus endpoint does
not export clickhouse_query_duration_seconds, so it could never fire.
52f6c04 to
405fbdf
Compare
|
@blue4209211 thanks. All four points are handled in 405fbdf (rebased on main, still 0.1.31).
On the 95% point: the values comment next to the insert guard says refused inserts are retried for the exporter's retry window, then dropped. Once the logs-backpressure PR (#678) lands, logs are held rather than dropped when inserts are refused. Whichever of the two merges second will reword that comment. Checks:
|
Summary
Logs, traces and metrics share the ClickHouse volume, and its TTL drops data by age, not by size. A noisy namespace can therefore fill the disk and stop every write, with no warning beforehand.
Alerts (3 rules):
ClickHouseInstanceDown: scrape failing or target absent for 2 minutes, critical.ClickHouseDiskFilling: any disk over 80% for 10 minutes, warning.ClickHouseDiskAlmostFull: any disk over 90% for 5 minutes, critical.The disk rules use ClickHouse's own
DiskAvailable_<disk>/DiskTotal_<disk>metrics.label_replacemoves the disk name into adisklabel, so every disk is covered.Insert guard:
merge_tree.min_free_disk_ratio_to_perform_insert = 0.05. Inserts are refused (NOT_ENOUGH_SPACE) while less than 5% is free. That leaves room for merges, TTL part drops and queries, instead of a full disk.New template
templates/clickhouse-prometheusrule.yamlrendersclickhouse.metrics.prometheusRule.rules. The Bitnami subchart has no PrometheusRule template, so these rules were never applied before. It renders only when a ClickHouse ServiceMonitor does and the PrometheusRule CRD is present (orenablePrometheusStackis set).Fixed
ClickHouseInstanceDown: it matchedup{job="clickhouse"}, but the operator setsjobto the Service name, so it never matched. Each expr now goes throughtpland selects this release'snamespaceandservice, so it also never matches another release's ClickHouse.Removed
ClickHouseHighLatency: ClickHouse does not exportclickhouse_query_duration_seconds, so it could never fire.For reviewers:
Type of change
Chart version
versionincharts/nudgebee-agent/Chart.yaml(required for user-visible changes): 0.1.31Test plan
helm lint charts/nudgebee-agentpasses.ct lint --config .github/configs/ct.yaml: run by CI.helm templatereviewed, includingfullnameOverride,nameOverrideandnamespaceOverride: the rule'snamespace/servicematch the scraped Service.promtool check rulesaccepts the 3 rendered rules, andpromtool test rulespasses (two disks,up == 0, absent target, no cross-release match).ClickHouseInstanceDownstays inactive once scraped.NOT_ENOUGH_SPACEwhile reads keep working.Related issues
None in this repo.