This guide shows how to connect a Cube deployment to Coalesce Quality. After the setup, each cube and each view of the deployment shows in Coalesce Quality as a semantic model, with lineage to your warehouse tables.It works for Cube Cloud and for self-hosted Cube Core, also for a deployment in a private network.⏱️ Estimated time to finish: 15 minutes.
How it works
Coalesce Quality reads the data model of the deployment. There are two ways, and they give the same result:- Coalesce Quality connects to Cube Cloud or to the Cube REST API and reads the data model on a schedule.
- You run
synq-cube, a small open source tool, beside Cube. It reads the data model and sends it to Coalesce Quality. Use it for a deployment in a private network: you open no port and allow no IP address.
Cube compiles the SQL and does not run it, so no query reaches your warehouse. Coalesce Quality never requests
/v1/load and reads no data rows.
On Cube Cloud, Coalesce Quality also reads the model export and the list of data sources from the Cube Cloud API.
What you get
- One asset for each cube and each view, with the title and the description from the data model. The assets are in the folders of their files in the data model.
- The semantic model of each: measures, dimensions and segments with their SQL, the type of each measure, measure filters, the primary key, the joins of a cube, and which members are not public.
- Lineage from the warehouse tables to the cubes, and from the cubes to the views. Column lineage goes from a warehouse column to the measure or the dimension that reads it, and then to the member of each view that includes it.
- The compiled definition of each cube and view on its Code tab. It is the data model after the render of Jinja templates and the merge of
extends. - A link from each cube and view to its file in your git repository, and to your deployment.
time_shift, reduce_by, group_by). The REST API of Cube Core does not return them, so on Cube Core the measure shows with its SQL only.
Before you start
You need:- A credential for Cube: an API key of Cube Cloud, or a credential for the Cube REST API (see The Cube token).
- For lineage to the warehouse: the warehouse of each Cube data source connected to Coalesce Quality as a data warehouse integration.
Set up the integration
- In Coalesce Quality, go to Settings → Integrations and add a Cube integration.
- Choose how Coalesce Quality gets the data model. You choose it one time. To use another way later, create a new integration.
- Enter the connection of that way:
- Cube Cloud
- Cube REST API
- Uploader
Enter the URL of your Cube Cloud account (
https://example.cubecloud.dev) and an API key. Then select the deployment and its environment from the list.Coalesce Quality creates a token for the deployment with the API key and reads the data model on a schedule. The default is each hour.The API key needs three permissions: the list of the deployments, the list of the environments of the deployment and the token for its metadata. Add a fourth one, the settings of the deployment, for the links to git (see Links to git). The synq-cube repository has the request that creates such a key.- Optional: name the warehouse integration of a Cube data source (see Lineage to the warehouse) and choose the git repository of the data model (see Links to git).
- Check the values on the last step and submit.
Check the result
After some minutes, the cubes and the views show in the catalog of Coalesce Quality, in the folders of their files in the data model. Open one cube and check its measures, its dimensions and its lineage to the warehouse tables. The Cube integration shows the time and the result of the last read. If a part of the data model has no lineage, the integration says which data source or which members, and why. The uploader also prints what it sent:Lineage to the warehouse
Each cube reads one data source of Cube, for exampledefault. Coalesce Quality must know which of your warehouse integrations a data source is.
- On Cube Cloud, Coalesce Quality reads what each data source is from Cube Cloud.
- The uploader reads it from the environment of Cube, or from its
--data-sourcesetting. - If nothing says what a data source is and your workspace has one warehouse integration, the data source is that warehouse.
Links to git
Coalesce Quality links each cube and each view to its file in your git repository. For the link, connect the repository to Coalesce Quality as a code integration: GitHub, GitLab or git over SSH. You set the repository in the Git repository step of the setup, or in the Git repository section of the Cube integration.- Cube Cloud
- Cube REST API and Uploader
Cube Cloud gives the branch of the deployment, so you need no setup. Coalesce Quality finds the Git integration that has the files of the data model on that branch, and the directory of the data model in it. The Git repository step shows the branch and the project directory that Cube Cloud gives.
- The project directory needs the permission
DeploymentsPublicController.getDeploymentSettingson the API key. Without it, the links still work if the data model is in a directory that Coalesce Quality can find, and the integration shows a warning. - If no Git integration has the files, or more than one has them, select the Git integration in the Git repository section. You can also set the branch and the data model directory there. Leave them empty to use the values from Cube Cloud.
- If Cube Cloud hosts the repository of the deployment, Coalesce Quality cannot read it, and the cubes and the views have no links to their files. To get the links, connect the deployment to your own Git repository in Cube Cloud, then add a Git integration for it.
The Cube token
The data model that Coalesce Quality shows is the data model that the token can see.API scopes
The token needs the API scopesmeta and sql. Cube gives both by default. If your deployment sets context_to_api_scopes, give the two scopes to the security context that you use for Coalesce Quality. The data scope is not necessary.
Without the sql scope, the cubes and the views still show, and the lineage to the warehouse tables is absent.
Read access to all members
Access policies andquery_rewrite apply to the security context of the token. A cube, a view or a member that is hidden from that security context is not in the data model that Coalesce Quality reads. Give the security context read access to all cubes, views and members. Set it as a JSON object in the integration, or in CUBE_SECURITY_CONTEXT of the uploader.
One integration for each tenant
A deployment withcontext_to_app_id compiles one data model for each tenant. One Cube integration is one data model, so create one integration for each tenant, each with its own deployment name and the security context of that tenant.
Asset IDs
Each cube and each view has anentity_id. The deployment name is a part of it, so a new deployment name gives each cube and each view a new entity_id. Do not build an entity_id from its parts. Get it from the Cube name, as Find a cube or a view by its Cube name shows.
Find a cube or a view by its Cube name
Each cube and each view has an external ID: the ID of the Cube integration and the name in the data model, as Cube spells it. Cube names are case sensitive, and so is the external ID.
The integration ID is in the address of the settings page of the Cube integration:
/settings/integrations/<integration ID>. ListIntegrations (GET /api/integrations/v1) also returns it. The external ID does not contain the deployment name, so it stays the same when the deployment name changes.
BatchResolveIdentifiers gives the entity_id of each external ID. QUALITY_API_ENDPOINT is developer.synq.io (EU), api.us.synq.io (US) or api.au.synq.io (AU). TOKEN is an access token of the API:
id.entityId of an entry only if its exists is true. If no cube or view has the external ID, exists is false.
Point a custom entity at a view
A custom entity, for example a dashboard that queries Cube, can read a view. Resolve the view as above. Then write the relationship with theentity_id in the synq_path variant:
BatchResolveIdentifiers reads it.
How removal works
Each read gives Coalesce Quality the whole data model. A cube or a view that is no longer in the data model is removed from Coalesce Quality. If you leave a part of the data model out with--include, --exclude or --skip-hidden of the uploader, use the same setting on each run.
If the data model that the token sees is empty, Coalesce Quality removes nothing and the integration shows an error.