Schedule icon
Query icon
Return icon
If icon
Create icon
SlackIncomingWebhook icon
Log icon

ClickHouse Storage Disk Space and Capacity Headroom Sentinel

Monitor ClickHouse disk capacity and prevent read-only table lockouts with Kestra. Query system.disks, open GitHub issues, and alert Data SRE on Slack.

Categories
DataInfrastructure

ClickHouse relies on local NVMe SSDs or mounted block storage volumes to store partitioned columnar data parts and perform asynchronous background merges (MergeTree). When available disk space drops below critical thresholds, ClickHouse automatically terminates background merges and places tables into read-only mode, refusing incoming real-time ingestion pipelines. This blueprint queries ClickHouse's system.disks table periodically via JDBC, identifies storage volumes breaching safe free space percentages, opens a prioritized GitHub Data SRE incident ticket, and alerts engineering teams on Slack.

How it works

  1. periodic_clickhouse_disk_check (io.kestra.plugin.core.trigger.Schedule) initiates the audit every 30 minutes (shipped disabled for safe verification).
  2. probe_clickhouse_disks (io.kestra.plugin.jdbc.clickhouse.Query) queries system.disks for total and free space bytes and calculates the free space percentage across all configured disks.
  3. evaluate_disk_headroom (io.kestra.plugin.core.debug.Return) calculates if the volume with the least free space breached free_space_percent_threshold.
  4. branch_on_disk_pressure (io.kestra.plugin.core.flow.If) evaluates the condition:
    • then: Automatically files a GitHub tracking issue via create_storage_incident_issue (io.kestra.plugin.github.issues.Create) and alerts the Slack channel via alert_data_sre_slack (io.kestra.plugin.slack.notifications.SlackIncomingWebhook).
    • else: Emits an informational log entry (log_storage_healthy) confirming ample storage headroom.
  5. log_audit_complete (io.kestra.plugin.core.log.Log) records the final audit outcome.
  6. The errors block alerts Slack if database authentication or network connectivity fails.

What you get

  • Automated, scheduled auditing of ClickHouse storage engine capacity.
  • Zero unexpected ingestion halts caused by sudden disk fill-ups.
  • Consolidated GitHub incident tickets with volume names, mount paths, and free space percentages.
  • Real-time Slack notifications with direct ticket hyperlinks.

Who it's for

  • Data Platform Engineers and ClickHouse Administrators operating analytical datalakes.
  • Site Reliability Engineers safeguarding real-time data streaming and metrics storage.
  • Infrastructure Architects sizing cloud storage volumes and retention policies.

Why orchestrate this with Kestra

Kestra simplifies multi-system reliability by connecting ClickHouse JDBC querying, mathematical threshold evaluation, GitHub issue ticketing, and team alerting into a single declarative pipeline. It manages database credentials securely, provides complete execution history, and eliminates the need for separate standalone monitoring daemons.

Prerequisites

  • A running ClickHouse cluster or standalone instance.
  • A ClickHouse user with read access on the system.disks administrative table.
  • A GitHub Personal Access Token with repository issue creation permissions.
  • A Slack incoming webhook URL for notifications.

Secrets

  • CLICKHOUSE_USER, CLICKHOUSE_PASSWORD: Authentication credentials for ClickHouse JDBC connection.
  • GITHUB_TOKEN: GitHub token used to open incident issues.
  • SLACK_WEBHOOK: Incoming Webhook URL for data platform alerts.

Inputs

  • clickhouse_url (STRING, default jdbc:ch://clickhouse.internal.company.com:8123/default): ClickHouse JDBC connection URL.
  • free_space_percent_threshold (FLOAT, default 15.0): Percentage of free space below which alerts fire.
  • target_repository (STRING, default my-org/data-platform-operations): Target GitHub repository for logging incident issues.

Outputs

  • outputs.probe_clickhouse_disks.row.name: Name of the storage volume with lowest headroom.
  • outputs.probe_clickhouse_disks.row.free_pct: Calculated free space percentage.
  • outputs.evaluate_disk_headroom.value.is_exhaustion_risk: Boolean indicating whether threshold was breached.

Quick start

  1. Configure CLICKHOUSE_USER, CLICKHOUSE_PASSWORD, GITHUB_TOKEN, and SLACK_WEBHOOK in your Kestra namespace.
  2. Import this flow and set clickhouse_url to match your cluster endpoint.
  3. Run the flow manually to verify disk metric calculation and Slack notification delivery.
  4. Enable the periodic_clickhouse_disk_check trigger for continuous storage headroom monitoring.

How to extend

  • Add an automated table partition drop or cold storage tiering task (ALTER TABLE ... MOVE PARTITION ... TO DISK 's3') to reclaim space.
  • Query system.parts to list the top 10 largest tables on the constrained volume.
  • Route urgent alerts to PagerDuty or Opsgenie if free disk space drops below 5%.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.