Skip to content

Dashboards as code

View as Markdownllms.txt

How to keep Superset dashboards in git: edit a dashboard in the Superset UI, export it back into lakehouse_code/dashboards/superset/, validate it and import it again. Dashboards need the Full preset, which adds Superset.

Set preset: full under spec in openlakeforge.yaml, then deploy:

spec:
provider:
type: local
preset: full
Terminal window
olf infra deploy --provider local

The deploy applies the change in place: Terraform adds OpenMetadata and Superset and leaves the data path and its tables as they are. Its artifacts phase imports every dashboard bundle under lakehouse_code/dashboards/superset/. olf infra status --provider local lists the Superset URL, for example http://superset-dev.olf.localhost. With sign-in off, Superset opens as its local Admin.

Each dashboard is a directory, a bundle, holding what Superset exports:

lakehouse_code/dashboards/superset/sales_customer_health/
├── metadata.yaml
├── databases/
├── datasets/
├── charts/
└── dashboards/

A directory under dashboards/superset/ is a dashboard once it holds a metadata.yaml, which the export writes. Its datasets name the Gold schema they read (schema: customer_health_gold), and that is how OpenLakeForge knows which products the dashboard serves. One dashboard can read several products.

The deploy requires exact parity between the declared dashboards and the bundle directories.

olf product new accepts --with-report when it creates a product. Use it for a new product, not one that already exists. The example reads the campaigns Silver table of a marketing domain, which must already exist; if it does not, create the source and the domain as in Build and manage data products.

Terminal window
olf product new marketing/campaign_summary \
--silver-input campaigns --gold-table mart_campaign_summary \
--with-report

It writes a draft under lakehouse_code/dashboards/superset/campaign_summary/: the Trino database, one dataset per Gold mart and a README. It adds no metadata.yaml, so the draft is not a dashboard or promotable yet, and the deploy does not import it into Superset.

Deploy the new product so the platform knows it, then build its table:

Terminal window
olf infra deploy --provider local --phase artifacts

In Dagster, launch campaign_summary_pipeline once, so campaign_summary_gold.mart_campaign_summary has rows.

Then build the dashboard in Superset: open Datasets, add a dataset from the OpenLakeForge Trino database, the campaign_summary_gold schema and the mart_campaign_summary table, chart it and save a dashboard. Then export it.

After you build or change a dashboard in the Superset UI, export it back into its bundle. olf infra report export takes the stage you authored in; author in DEV. For the campaign_summary draft of step 3, which has nothing exported yet, name the dashboard by the slug you gave it in Superset (its Properties):

Terminal window
SUPERSET_REPORT_SOURCE_DIR=lakehouse_code/dashboards/superset/campaign_summary \
SUPERSET_DASHBOARD="campaign-summary" \
olf infra report export --stage dev

For a dashboard that is already in a bundle, such as the demo sales_customer_health, set only SUPERSET_REPORT_SOURCE_DIR to its directory.

  • SUPERSET_REPORT_SOURCE_DIR picks the bundle. It must be a directory directly under lakehouse_code/dashboards/superset/. Without it the command exports the first dashboard bundle it finds.
  • The dashboard is found by the uuid stored in the bundle, which survives a rename in Superset. For a draft with nothing exported yet, set SUPERSET_DASHBOARD to its uuid or slug.
  • SUPERSET_ADMIN_USERNAME defaults to admin. The password is read from the superset-credentials Secret in the stage namespace; set SUPERSET_ADMIN_PASSWORD to use another Superset.

The export writes a stage-neutral bundle: it replaces DEV’s live Trino connection with the placeholder each deploy rewrites, so the same bundle can be promoted to PROD.

The export writes campaign_summary’s metadata.yaml, which makes it a dashboard next to the demo ones.

The next olf infra deploy imports every bundle. To import without a full deploy:

Terminal window
olf infra report import --stage dev

olf infra project build packages the bundles into a project revision, so a revision promoted to PROD carries its dashboards.

Terminal window
olf report validate

It checks every bundle for stable identities, resolvable references and no stage-bound values. With the three demo dashboards and campaign_summary exported, it prints:

4 report bundle(s) are promotable.

Pass a dashboard name to check only that one.


Synced from openlakeforge @ v0.6.0-alpha.3 (882b426), docs/guides/dashboards-as-code.md.