Cube
Connect Cube to Weld so an orchestration builds your Cube pre-aggregations as soon as the syncs and models they read from have finished. Weld waits until Cube has built them, so the orchestration only completes once Cube serves the new data.
Before you start
- A Cube deployment with at least one pre-aggregation, and access to its environment variables.
jobsin the deployment'sCUBEJS_DEFAULT_API_SCOPES. Weld starts and follows builds through Cube's jobs API, which is not in Cube's default scopes.- Triggering Cube from Weld is part of orchestration, which is included in the Premium plan and above.
Step 1: Connect Cube
- Open the orchestration that syncs the data your cubes read, and click the Webhooks tab.
- Click Set up Cube connection.
- Fill in the connection and click Connect:
- Name: a name for the connection.
- Cube API URL: the REST API URL of your Cube deployment, for example
https://thirsty-raccoon.aws-eu-central-1.cubecloudapp.dev. The/cubejs-api/v1suffix is optional. - API secret: the deployment's
CUBEJS_API_SECRET. Weld signs a short-lived token with it for every request.
Weld checks the URL, the secret and the jobs scope before it saves the connection.
Step 2: Build pre-aggregations after your syncs
- On the Webhooks tab, click Create webhook.
- Fill in the webhook and click Save:
- Name, for example
build_cube_after_syncs. - External System: Cube.
- Select pre-aggregations to build: All pre-aggregations, every pre-aggregation of one cube, or a single pre-aggregation such as
orders.daily_revenue. - Select job(s) to run after: the jobs in this orchestration that must finish first. These can be data source syncs, models, reverse ETL syncs or another webhook, such as a dbt Cloud job.
From then on, each time the orchestration runs, Weld starts the Cube build once the chosen jobs have finished and follows it until Cube has built every pre-aggregation you picked. The latest run shows next to the webhook on the Webhooks tab.
Troubleshooting
Connecting fails with a message about CUBEJS_DEFAULT_API_SCOPES. The deployment doesn't allow the jobs API. Add jobs to CUBEJS_DEFAULT_API_SCOPES alongside the scopes you already use, redeploy Cube, and connect again.
Connecting fails with "Could not reach the Cube API". Check the URL: it should be the deployment's REST API URL, and Weld must be able to reach it.
The webhook run failed. At least one of the selected pre-aggregations failed to build in Cube. Check the build in Cube, fix it, and run the orchestration again.
The webhook run timed out. The build was still running after 60 minutes. Build fewer pre-aggregations per webhook, for example one webhook per cube.