Dashboards as code is in preview. Contact your Cube representative to enable
it for a deployment.
When to use it
Reach for dashboards as code when you want to:- Review dashboard changes in Git — treat a dashboard edit like any other code change, with diffs, pull requests, and approvals.
- Promote across environments — apply the same definitions to staging and production, or to many deployments, from one CI/CD pipeline.
- Keep dashboards reproducible — the definition is the source of truth, not a database row, so a deployment rebuilt from the repository has the same dashboards.
How it works
Dashboards as code builds on Git-based continuous deployment. You add adashboards/ directory to your
project (alongside model/), commit dashboard and chart YAML files to it, and
deploy your project as usual. Cube Cloud reads that directory at build time and
serves the dashboards to the workspace.
- Folders come from the directory structure. A file at
dashboards/finance/emea/revenue.yamlplaces its dashboard in thefinance → emeafolder of the workspace. You organize dashboards by moving files between directories. - Nothing is persisted separately. The definitions are read live from the deployed source and are versioned and redeployed with your model — there is no separate database copy to keep in sync.
- Everything is read-only in the UI. Source-owned dashboards render through the same viewer as published dashboards, but the workspace exposes no editing for them. Charts still run their queries live, so the data is current.
dashboards/ at the project root. To use a
different location, set the CUBE_CLOUD_DASHBOARDS_CONFIG_PATH environment
variable to the path you want.
Project layout
apiVersion:
Both kinds can live anywhere under
dashboards/; Cube routes each file by its
apiVersion. Only a dashboard file’s directory affects the folder tree — chart
files are referenced by id, so their location is up to you (grouping them under
charts/ is a convention, not a requirement).
Dashboard files
A dashboard file describes the layout and the widgets on the canvas.dashboards/revenue-overview.yaml
Widgets
Each widget is an object with anid, a type, and a position:
The widget types mirror the ones in the dashboard builder: charts
visualize a report, text adds Markdown, controls (
FILTER / TIME_GRAIN) let
viewers filter or change the time granularity, and AI summaries generate
narrative text.
Tabbed widgets
ATABS_CONTAINER groups widgets into tabs. Each tab has an id, a title, and
its own children — which are ordinary widgets, including nested charts:
Chart files
A chart file holds a chart’s query and its visualization spec. It is referenced by dashboard widgets through itspublicId, so the same chart can appear on more
than one dashboard.
dashboards/charts/revenue_by_month.yaml
Chart publicId
The publicId is the chart’s portable identity: dashboards reference it, and it
is what keeps a reference stable across deployments and edits. Choose a
12-character alphanumeric id ([0-9A-Za-z]) and keep it fixed for the life of the
chart. It must be unique within the deployment — two chart files with the same
publicId fail the build.
Visualization spec
Thechart block holds the visualization spec. Its shape mirrors what the
dashboard builder produces:
chartCategorynames the chart type.- The spec itself lives in a matching field:
tableChartSpec,vegaSpec,kpiChartSpec,htmlChartSpec, ormapChartSpec. The render type is one oftable,vega,kpi,html, ormap.
query.sql is the source of truth for a chart’s query. The chart is rendered by
running that SQL live in the browser, so the data is always current — the file
stores the definition, never a cached result.Referencing charts from widgets
ACHART widget names the chart it renders with chart: <publicId>:
publicId (not by a per-deployment numeric
id), a dashboard and its charts move together across environments unchanged. A
widget whose chart id has no matching chart file simply renders nothing.
Folders
The directory a dashboard file lives in becomes its folder in the workspace, and the directory tree becomes the folder tree. A dashboard at the root ofdashboards/ appears at the top level; one at dashboards/finance/emea/ appears
under finance → emea. Ancestor folders (finance) are created automatically
even if they contain no dashboard file of their own.
A complete example
dashboards/revenue-overview.yaml
dashboards/charts/revenue_by_month.yaml
dashboards/charts/revenue_by_status.yaml
Deploying
Dashboards as code is deployed like the rest of your project:- Add the dashboard and chart files under
dashboards/in your repository. - Open a pull request and review the change like any other code change.
- Merge and deploy — with Git-based deployment, the production branch builds automatically; with CLI deployment, run your usual deploy command.
Validation and rules
Cube validates the source tree at build time. A problem fails the load with a message naming the file, so you catch it in your build rather than at runtime:apiVersionis required and must match. Files without a recognizedapiVersionare ignored; a recognized one with an invalid body fails validation.- Slugs are unique. Two dashboards with the same
slugare rejected. - Chart
publicIds are unique. Two chart files with the samepublicIdare rejected. - YAML must parse. A malformed file fails with a parse error naming the file.
- Unknown fields are preserved. Fields beyond the documented ones round-trip untouched, so a newer authoring field is never dropped by the runtime.