Query icon
Return icon
Switch icon
Log icon
SlackIncomingWebhook icon
Schedule icon

Cassandra Thread Pool Exhaustion and Blocked Tasks Sentinel

Monitor Cassandra 4.0+ thread pools for blocked and pending tasks to detect cluster saturation and trigger real-time Slack alerts before nodes drop queries.

Categories
DataInfrastructure

Apache Cassandra relies on staged event-driven architecture (SEDA) thread pools (such as MutationStage, ReadStage, CompactionExecutor, and Native-Transport-Requests) to handle concurrency, read/write I/O, and background maintenance. Under sudden write bursts, slow storage, or JVM garbage collection pauses, task queues fill up and tasks become blocked, leading to client request drops, elevated P99 latency, and cluster degradation. Cassandra 4.0 introduces the system_views.thread_pools virtual table, exposing in-memory thread pool metrics directly over native CQL without requiring external JMX exporters. This blueprint audits Cassandra thread pools on a schedule, detects backlog accumulation or blocked tasks, logs diagnostic telemetry, and dispatches real-time incident notifications to Slack.

How it works

  1. periodic_thread_pool_audit (io.kestra.plugin.core.trigger.Schedule) initiates scheduled monitoring every 5 minutes (shipped disabled for safe onboarding).
  2. probe_thread_pools (io.kestra.plugin.cassandra.standard.Query) queries the native CQL virtual table system_views.thread_pools to extract name, active_tasks, pending_tasks, and blocked_tasks with fetchType: FETCH and allowFailure: true.
  3. classify_thread_pools (io.kestra.plugin.core.debug.Return) evaluates virtual table outputs using Pebble expressions and jq filters, categorizing the node state as HEALTHY (zero blocked tasks and pending queues within limit), EXHAUSTED (any stage with blocked tasks > 0 or pending tasks > max_pending_threshold), or UNREACHABLE (connection failure or empty output).
  4. route_by_saturation (io.kestra.plugin.core.flow.Switch) routes downstream actions based on the evaluated state:
    • HEALTHY: logs cluster stability and pool counts via log_healthy_pools.
    • EXHAUSTED: sends an incident alert to Slack with the offending stage details via alert_thread_pool_exhaustion and emits remediation runbook instructions through log_exhaustion_telemetry.
    • UNREACHABLE: dispatches a node connectivity alert via alert_unreachable_node and records a warning log.
  5. audit_sentinel_run (io.kestra.plugin.core.log.Log) produces a structured execution recap tracking the inspected host, datacenter, pool count, and classification verdict.
  6. handle_execution_failure in the flow-level errors handler catches unhandled workflow execution errors and notifies Slack.

What you get

  • Proactive detection of Cassandra thread pool bottlenecks before clients experience read/write timeouts.
  • Zero JMX dependency by leveraging Cassandra 4.0+ native CQL virtual tables (system_views.thread_pools).
  • Rich contextual incident alerts in Slack detailing the exact saturated thread pool names and queue depths.
  • Automated triage runbook guidance in logs pointing engineers directly to root causes (disk I/O, GC pauses, compaction lag).
  • Safe-by-default execution with parameterized thresholds and an initially disabled schedule.

Who it's for

  • Database Reliability Engineers (DBREs) managing distributed Cassandra clusters.
  • Platform and Site Reliability Engineers (SREs) operating mission-critical low-latency data pipelines.
  • DevOps engineers seeking lightweight database health checks without deploying heavy monitoring agents.

Why orchestrate this with Kestra

Operating Cassandra at scale requires continuous visibility into internal stage queues, but traditional monitoring often depends on fragile JMX exporters, Jolokia sidecars, or complex external scraping stacks that require daemon maintenance. Orchestrating thread pool health checks directly through Kestra provides:

  • Declarative, version-controlled Cassandra health automation running as standard workflows.
  • First-class Pebble and jq transformations to classify multi-stage metrics into actionable operational states without maintaining glue code.
  • Centralized secrets management ensuring database credentials and Slack webhooks are securely handled.
  • Native execution history and full execution audit trails across every scheduled check.

Prerequisites

  • A running Apache Cassandra 4.0+ cluster or open-source Docker container (cassandra:4.1).
  • Network connectivity from the Kestra worker to the Cassandra native CQL transport port (default 9042).
  • A Slack Incoming Webhook URL with posting permissions to the designated operations channel.

Secrets

  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL used by SlackIncomingWebhook to send incident and probe failure notifications.
  • CASSANDRA_USERNAME: (Optional) Administrative CQL username if authentication is enabled on the cluster.
  • CASSANDRA_PASSWORD: (Optional) Administrative CQL password corresponding to CASSANDRA_USERNAME.

Quick start

  1. Store your Slack Incoming Webhook URL in Kestra Secrets under the key SLACK_WEBHOOK_URL (or provide it via the slack_webhook flow input).
  2. If your Cassandra cluster enforces password authentication (PasswordAuthenticator), configure CASSANDRA_USERNAME and CASSANDRA_PASSWORD in Kestra Secrets and add credentials to session.
  3. Execute the flow manually from the Kestra UI to verify successful connection and metric retrieval against your target node.
  4. Review execution logs to confirm all thread pools are reported with zero blocked tasks.
  5. Enable the periodic_thread_pool_audit trigger to start continuous 5-minute automated sentinel monitoring.

How to extend

  • Auto-remediation with nodetool: Add an SSH or container execution task that runs nodetool setconcurrency or adjusts dynamic compaction throughput when specific thread pools spike.
  • Multi-node cluster scanning: Wrap the probe task in a ForEach loop iterating over all coordinator and replica node IPs in the cluster.
  • PagerDuty integration: Pair the Slack notification with io.kestra.plugin.pagerduty.Incident for critical EXHAUSTED alerts occurring during peak business hours.
  • Metrics export to Prometheus: Forward thread pool metrics to a Pushgateway or metrics sink for historical trend analysis.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.