Schedule icon
Request icon
Switch icon
Log icon
SlackIncomingWebhook icon

Cube.js Pre-Aggregation Table Freshness and Build Sentinel

Audit Cube.js semantic layer pre-aggregation partitions and build status, detect refresh failures, and dispatch automated Slack incident alerts.

Categories
Data

Automated drift auditor and health gate that continuously monitors Cube.js universal semantic layer pre-aggregation tables and partition build statuses. Dispatches structured Slack incident notifications upon build failures or missing pre-aggregation models, preventing expensive raw table scans and degraded analytical dashboard response times.

How it works

  1. A recurrent scheduled trigger initiates the pre-aggregation audit on a 4-hour interval, or triggers on-demand via webhook after upstream dbt or ETL warehouse runs.
  2. The probe_cube_readiness task queries GET /readyz on the target Cube.js server to confirm HTTP service status and background orchestration readiness.
  3. The probe_pre_aggregations_status task queries GET /cubejs-api/v1/pre-aggregations using an authenticated API token to extract partition metadata, build statuses, and error details across registered cubes.
  4. Pebble expressions inspect the returned pre-aggregation catalog, isolating tables belonging to the specified target_cube, counting build failures, and checking partition availability against min_expected_pre_aggregations.
  5. The evaluate_pre_aggregation_health flow-control Switch evaluates the classified operational state:
    • COMPLIANT: Logs clean audit metrics when all expected pre-aggregation tables are built and healthy.
    • BUILD_FAILED: Formats and dispatches a rich Slack warning containing target cube details and failed partition alerts.
    • PRE_AGGREGATION_MISSING: Posts a high-priority Slack incident alert notifying data engineers that pre-aggregation definitions or storage tables are missing.
    • SERVICE_UNHEALTHY: Alerts on-call teams immediately if the Cube.js readiness probe returns non-ok status.
  6. A final log_audit_summary task records execution audit telemetry, and an errors block intercepts connection timeouts or authentication failures with automated Slack escalations.

What you get

  • Proactive pre-aggregation partition build failure detection before business users experience broken BI dashboards.
  • Continuous surveillance of semantic layer acceleration tables preventing unexpected cloud warehouse cost spikes.
  • Automated Slack incident routing with detailed contextual payload attachments identifying failing cube models.
  • Verifiable operational gate that can be chained downstream of warehouse loading pipelines before refreshing analytical models.
  • Centralized audit trail of semantic layer health preserved directly within Kestra's execution history.

Who it's for

  • Analytics Engineers and Data Platform Teams managing Cube.js semantic layers and embedded analytics.
  • BI Engineers responsible for executive dashboard SLAs and query performance.
  • Data Engineers orchestrating end-to-end ELT, dbt, and semantic caching workflows.

Why orchestrate this with Kestra

  • Declarative Semantic Governance: Codify pre-aggregation health policies, minimum table thresholds, and escalation paths in revision-controlled YAML workflows.
  • Native Secret Isolation: Securely manage Cube API tokens and Slack webhook URLs in namespace secret stores via {{ secret(...) }} without plaintext exposure.
  • Coordinated Data Pipeline Triggers: Trigger this sentinel automatically after upstream dbt transformations or data warehouse loading flows finish.
  • Resilient Multi-State Routing: Differentiate between infrastructure downtime, partition build stalls, and schema configuration errors using native Pebble logic and Switch tasks.

Prerequisites

  • A running Cube.js instance (accessible over HTTP/HTTPS) with the REST API and pre-aggregations management enabled.
  • Network connectivity from the Kestra worker or runner environment to the Cube.js server.
  • A Slack Incoming Webhook URL configured with permissions to post into your target operations channel.

Secrets

  • CUBEJS_API_TOKEN: Administrative API secret or JWT token for authenticating against the Cube.js REST API.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook endpoint URL used for operational alerts.

Quick start

  1. Configure the required secrets (CUBEJS_API_TOKEN, SLACK_WEBHOOK_URL) in your Kestra namespace settings.
  2. Import this blueprint into your Kestra instance under your desired namespace (e.g., company.analytics).
  3. Click Execute with default inputs or provide your custom cube_host and target_cube to validate connectivity against your instance.
  4. Review execution logs under the Executions tab to confirm that pre-aggregation partition statuses are retrieved and parsed correctly.
  5. Enable the scheduled_sentinel_audit trigger to establish recurrent 4-hour automated freshness evaluations.

How to extend

  • Automated Pre-Aggregation Rebuild: Extend the build failure branch with an HTTP request to trigger a forced rebuild (POST /cubejs-api/v1/pre-aggregations/jobs).
  • Upstream dbt Pipeline Integration: Trigger this flow as a downstream dependency using a Kestra Flow trigger immediately following dbt model materialization.
  • PagerDuty Escalation: Route critical SERVICE_UNHEALTHY states directly to PagerDuty or Opsgenie on-call schedules.
  • Multi-Cube Sweep: Combine with a Kestra ForEach loop task to iterate across an array of critical semantic cube models.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.