Schedule icon
Request icon
Return icon
Switch icon
Log icon
SlackIncomingWebhook icon
If icon
OutputValues icon

GreptimeDB Storage Compaction and Ingestion Health Sentinel

Audit GreptimeDB time-series database health, monitor table inventory, classify node status, and trigger automated LSM-tree storage compaction via Kestra.

Categories
Infrastructure

Continuously audits GreptimeDB time-series clusters by probing administrative health endpoints, verifying table inventory across information schemas, classifying node availability, alerting engineering teams on Slack, and orchestrating guarded storage compaction.

How it works

  1. probe_greptimedb_health issues an HTTP GET probe against /health to verify that the GreptimeDB HTTP server and runtime loops are operational.
  2. probe_table_inventory queries information_schema.tables via the /v1/sql HTTP endpoint, extracting active table counts and storage engines.
  3. classify_health_status evaluates response codes and table metrics through a Pebble conditional expression, categorizing the cluster into HEALTHY, WARNING, CRITICAL, or NODE_UNREACHABLE.
  4. route_by_health_status switches execution based on classification:
    • HEALTHY: Logs database metrics, total active tables, and SQL query execution latency.
    • WARNING: Dispatches a Slack notification warning of table count anomalies, and if enabled, delegates to safe table compaction.
    • CRITICAL: Alerts on-call engineers via Slack that /v1/sql queries are failing despite a reachable process.
    • NODE_UNREACHABLE: Notifies operations that GreptimeDB HTTP port 4000 is down or experiencing network partitions.
  5. check_auto_compaction evaluates auto_compact and dry_run inputs. When enabled with dry_run: false, it issues ADMIN COMPACT_TABLE('<target_table>', 'regular') to merge fragmented SST files and purge expired rows.
  6. log_audit_summary produces structured outputs capturing health classifications and execution parameters for compliance tracking.
  7. errors captures unexpected task exceptions and posts a high-priority incident notice to Slack.

What you get

  • Automated, scheduled validation of GreptimeDB cluster availability without requiring third-party monitoring agents.
  • Early detection of table schema drift, unexpected table drops, or query execution timeouts.
  • Zero-dependency administrative compaction execution to prevent SST file fragmentation, high read amplification, and storage bloat.
  • Guarded remediation architecture pairing auto_compact with a mandatory dry_run safety latch.
  • Instant Slack incident notifications containing exact execution IDs and diagnostic context.

Who it's for

  • Platform Engineers and Site Reliability Engineers managing GreptimeDB deployments in production.
  • Time-series and IoT Data Engineers ingesting high-throughput metrics and telemetry into GreptimeDB.
  • Database Administrators seeking automated Day-2 maintenance, compaction schedules, and health alerting.

Why orchestrate this with Kestra

Time-series databases like GreptimeDB continuously ingest high-velocity data, causing rapid accumulation of uncompacted SST files and MemTable flushes. Running unmanaged cron scripts to monitor health or trigger maintenance lacks observability, centralized secret management, retry mechanisms, and auditable history. Kestra provides declarative, reproducible orchestration with built-in scheduling, granular failure alerts, dynamic parameterization, and stateful tracking across all cluster nodes.

Prerequisites

  • A running GreptimeDB instance (standalone or distributed cluster) with HTTP port 4000 accessible from the Kestra worker.
  • An incoming Slack webhook URL for alert routing.

Secrets

  • SLACK_WEBHOOK: Incoming Slack webhook URL used by alert_warning_slack, alert_critical_slack, alert_unreachable_slack, and the errors handler.

Quick start

  1. Configure the SLACK_WEBHOOK secret within your Kestra namespace or environment variables.
  2. Start a local GreptimeDB instance with Docker:
    docker run -d --name greptimedb -p 4000:4000 greptime/greptimedb:latest standalone start
    
  3. Execute this flow manually in Kestra with dry_run: true to verify connectivity against greptimedb:4000 (or localhost:4000).
  4. Provide a target_table name (e.g., cpu_metrics) and set auto_compact: true with dry_run: false to test automated compaction.
  5. Enable the every_15_minutes trigger to automate continuous health monitoring and maintenance.

How to extend

  • Add a preliminary task using io.kestra.plugin.scripts.shell.Commands to scrape /metrics and alert on write amplification or disk queue depth.
  • Extend compaction routing to iterate dynamically over multiple high-throughput tables using io.kestra.plugin.core.flow.Loop.
  • Route critical alerts to PagerDuty or Opsgenie using dedicated Kestra notification plugins.
  • Integrate downstream dbt or SQL transforms that run immediately after compaction confirms table optimization.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.