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/, declare it in lakehouse.yaml, 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 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 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 bundle is promotable only when lakehouse.yaml declares it and the products it reads. One dashboard can read several products:

dashboards:
- name: sales_customer_health
products: [customer_health]

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 and no dashboards: entry, so the draft is neither declared nor 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 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 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 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 declared in lakehouse.yaml.
  • 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 and SUPERSET_ADMIN_PASSWORD default to admin and admin.

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.

Then declare the new dashboard in lakehouse.yaml, next to the demo ones:

dashboards:
- name: campaign_summary
products: [campaign_summary]

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

Terminal window
olf report import --stage dev

olf 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 declared, it prints:

4 report bundle(s) are promotable.

Pass a dashboard name to check only that one. Without a name, the command also fails when a bundle directory is not declared in lakehouse.yaml.


Synced from openlakeforge @ v0.5.0-alpha.1 (1598142), docs/guides/dashboards-as-code.md.