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/, declare it in
lakehouse.yaml, 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 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 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 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.
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 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:
olf 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 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 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 declared inlakehouse.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_DASHBOARDto its uuid or slug. SUPERSET_ADMIN_USERNAMEandSUPERSET_ADMIN_PASSWORDdefault toadminandadmin.
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]5. Import a bundle
Section titled “5. Import a bundle”The next olf deploy imports every bundle. To import without a full deploy:
olf report import --stage devolf 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
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.