Schedule icon
Webhook icon
Request icon
Script icon
Docker icon
If icon
Log icon
SlackIncomingWebhook icon
Fail icon

Gate ScyllaDB Reporting Queries on Tombstone Scan Ratio and Read Latency

Enforce ScyllaDB query safety by tripping circuit breakers on tombstone ratios over 10:1 and triggering automated table compaction via REST API.

Categories
DataInfrastructure

Evaluate ScyllaDB tombstone-to-live-row scan ratio and query read latency from Prometheus metrics, trip a circuit breaker on reporting pipelines if the ratio exceeds 10:1, and trigger automated keyspace table compaction via REST API.

How it works

  1. The workflow triggers via a periodic Schedule (every 15 minutes) or on-demand Webhook invoked prior to dispatching scheduled analytical reporting jobs.
  2. An HTTP request fetches real-time partition scan metrics from the ScyllaDB Prometheus endpoint (port 9180), Prometheus query API, or nodetool REST proxy.
  3. A Python container script parses the telemetry payload, extracting scylla_query_tombstones_scanned_total and scylla_query_rows_read_total for the target keyspace and table, alongside coordinator read latency distributions.
  4. The script computes the tombstone-to-live-cell ratio (tombstones_scanned / max(rows_read, 1)). If the ratio breaches the safety threshold (default 10:1) or read latency exceeds max_read_latency_ms (default 50ms), the circuit breaker is flagged as tripped.
  5. An If conditional routes execution based on the breaker state:
    • When Tripped: Logs detailed warnings, triggers major or minor compaction (POST /storage_service/keyspace_compaction/{keyspace}?cf={table}) via the ScyllaDB REST administration API, dispatches an incident alert to Slack, and halts execution via Fail to block downstream reporting jobs.
    • When Healthy: Logs nominal verification metrics, allowing downstream reporting pipelines to proceed safely without risk of node latency degradation.

What you get

  • Automated tombstone ratio calculation preventing unbounded wide-partition scans across soft-deleted rows.
  • Fail-closed circuit breaker protection halting scheduled reporting batch queries before node latency cascades.
  • Proactive table-level major or minor compaction triggered via ScyllaDB REST API.
  • Bounded JSON audit report output (tombstone-latency-report.json) detailing scanned counts, latencies, and breaker status.
  • Real-time Slack notifications alerting database operators to degraded keyspaces and initiated maintenance.

Who it's for

  • Database Administrators (DBAs) managing ScyllaDB or Cassandra clusters with high update/delete churn.
  • Analytics and Data Engineers scheduling heavy queries over wide time-series or event tables.
  • Site Reliability Engineers (SREs) safeguarding NoSQL database read latency SLAs.

Why orchestrate this with Kestra

  • Unifies Prometheus metric extraction, statistical ratio calculation, conditional flow gating, REST API remediation, and Slack alerting into one declarative workflow.
  • Avoids brittle, unmonitored bash or cron scripts by providing centralized execution logs, audit trails, and automatic retries.
  • Acts as a native upstream dependency gate in Kestra that downstream reporting workflows can listen to or execute conditionally.

Prerequisites

  • Kestra instance with Docker runner access.
  • Reachable ScyllaDB Prometheus metrics endpoint (http://<scylla-node>:9180/metrics or Prometheus API http://<prometheus>:9090).
  • Reachable ScyllaDB administrative REST API (default port 10000, e.g. http://<scylla-node>:10000).
  • Network connectivity from Kestra workers to the database cluster and Slack webhook endpoint.

Secrets

  • SCYLLADB_METRICS_URL: URL to ScyllaDB Prometheus metrics endpoint (e.g. http://scylla-node:9180/metrics) or Prometheus server query API.
  • SCYLLADB_METRICS_TOKEN: Optional bearer token or credentials header for ScyllaDB metrics endpoint authentication.
  • SCYLLADB_API_URL: Base URL for the ScyllaDB REST administration API (default port 10000, e.g. http://scylla-node:10000).
  • SCYLLADB_API_TOKEN: Bearer token or credentials header for ScyllaDB REST API authentication.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL to receive circuit-breaker alerts and remediation notifications.
  • SCYLLADB_GUARD_WEBHOOK_KEY: Secret authentication key for the inbound Webhook trigger.

Quick start

  1. Store required secrets in your Kestra namespace (SCYLLADB_METRICS_URL, SCYLLADB_METRICS_TOKEN, SCYLLADB_API_URL, SCYLLADB_API_TOKEN, SLACK_WEBHOOK_URL, SCYLLADB_GUARD_WEBHOOK_KEY).
  2. Import this blueprint flow into your Kestra environment under company.team.
  3. Test execute the flow manually with your target keyspace and table inputs to confirm metrics connectivity.
  4. Enable the schedule trigger or call the webhook trigger prior to executing your scheduled reporting workloads.

How to extend

  • Connect downstream reporting workflows via Kestra flow triggers to run automatically only when this safety gate finishes with state SUCCESS.
  • Add multi-node metric aggregation across all cluster coordinator endpoints before evaluating the tombstone ratio.
  • Integrate PagerDuty or Opsgenie plugins alongside Slack for automated on-call incident escalation during severe latency spikes.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.