Dashboards as code
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.
1. Use the Full preset
Section titled “1. Use the Full preset”Set preset: full under spec in openlakeforge.yaml, then deploy:
spec: provider: type: local preset: fullolf infra deploy --provider localThe 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.
2. Know the bundle
Section titled “2. Know the bundle”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.
3. Start a new dashboard
Section titled “3. Start a new dashboard”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.
olf product new marketing/campaign_summary \ --silver-input campaigns --gold-table mart_campaign_summary \ --with-reportIt 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:
olf infra deploy --provider local --phase artifactsIn 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.
4. Export a dashboard
Section titled “4. Export a dashboard”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):
SUPERSET_REPORT_SOURCE_DIR=lakehouse_code/dashboards/superset/campaign_summary \SUPERSET_DASHBOARD="campaign-summary" \ olf infra report export --stage devFor 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_DIRpicks the bundle. It must be a directory directly underlakehouse_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_DASHBOARDto its uuid or slug. SUPERSET_ADMIN_USERNAMEdefaults toadmin. The password is read from thesuperset-credentialsSecret in the stage namespace; setSUPERSET_ADMIN_PASSWORDto 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.
5. Import a bundle
Section titled “5. Import a bundle”The next olf infra deploy imports every bundle. To import without a full deploy:
olf infra report import --stage devolf infra project build packages the bundles into a project revision, so a revision
promoted to PROD carries its dashboards.
Check it worked
Section titled “Check it worked”olf report validateIt 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.