Introducing Dashboards as Code

Introducing Dashboards as Code

Oliver Laslett

January 16, 2025

Today we’re launching Dashboards as Code, a new way to manage your dashboards using YAML. This opens up new exciting workflows that would be impossible or impractical to implement using only the UI.

Manage your dashboards as YAML files

Once a BI project reaches hundreds of dashboards, it becomes very difficult to govern and maintain consistency. Making changes like renaming metrics or tables, or duplicating content at scale becomes really hard because making repetitive changes through the UI is slow and error-prone.

In Lightdash, you can now manage all your charts and dashboards as YAML files, in a git repository. You can even use your existing dbt repository, so you can store all your data models, transformations, and BI content in one place (as the data gods intended).

For data teams, this means your content is version-controlled giving a lot of options for rolling-back, disaster recovery, and governance. Even better, you can make bulk changes safely without repetitive UI tasks.

Get started with Dashboards as Code

To get started, open your terminal and upgrade your Lightdash CLI. Then download all your content by using the download command (available to admins only):


lightdash download

This will create a new folder for your content containing a YAML file for each chart and dashboard in your project. First you should check these files into git. You could do this in a new repository or in your existing dbt repository to keep your dashboard definitions right next to your dbt model and metric definitions.


# Your downloaded content will look like this
.
├── charts
│   ├── revenue-per-month.yml
│   ├── revenue-this-quarter.yml
│   └── top-products-this-month.yml
└── dashboards
    └── kpi-dashboard.yml

Notice that each chart and dashboard has a slug which is a unique identifier for the resource. If you want to change a chart or a dashboard you should keep this slug consistent.

Let's say we want to make a change to a chart, we can manipulate the YAML. For example, here I'll update the chart from a line chart to a bar chart:


slug: revenue-per-month   # Do not change this!
name: Revenue over time   # You can change the chart name
metricQuery:              # Change the underlying query
  dimensions:
    - month
  metrics:
    - revenue
...
chartConfig:             # You can change the chart styling
  type: cartesian
  config:
    eChartsConfig:
      series:
        - type: bar      # Update bars to a line
...

Once you've made your changes you can re-upload the specific chart by using the upload command:


lightdash upload -c my-chart-slug

Here we used -c to sub-select a specific chart. You can read more information on selectors in our docs. This covers the basics of how to download and upload your dashboards as code. Now let's see how we can combine these actions to build powerful code-based workflows.

Example: Rename a table or metric in Lightdash

A common BI refactoring task is when you've had to rename a table or metric in dbt. With Dashboards as Code you can now make these changes with one quick find-and -replace instead of using the Lightdash UI to manually find and update multiple charts.g

In the example below, I find a metric in my project and use my code editor's features to find all references to the metric and replace them. This was much faster and more reliable than doing it manually!

Customer spotlight: How Kraken manages multiple Lightdash projects at scale

Kraken is an end-to-end platform for utilities. They manage over 60 million customer accounts, more than 50 GW of power, and over 300,000 consumer devices such as electric cars and charging stations.

At Kraken, one of the big challenges they faced using Lightdash was being able to create and manage a lot of Lightdash projects in a fast and error-resilient way. And for them, managing dashboards as code was a huge improvement to their workflow.

Kraken’s deployments work a bit like this:

  • Kraken has a bunch of utility companies as customers
  • each company’s profile falls into a few categories (e.g. EMEA / APAC / US, water / gas / electricity, etc.)
  • depending on each category that the utility company belongs to, they should get specific dashboards in their Lightdash project
  • they use a single CI/CD pipeline to then deploy and sync many Lightdash projects at once

With dashboards as code, Kraken has managed to create dbt + Lightdash packages that create the correct models and dashboards automatically, so managing Lightdash projects at scale is faster and easier than ever.

We think it’s pretty great, but here’s what Kraken has to say about it:

Lightdash’s dashboards-as-code approach is transforming how we manage analytics at Kraken. By integrating dashboard changes directly into our CI/CD pipeline, we’re achieving both lightning-fast deployments and bulletproof governance - solving two of our biggest BI challenges in one stroke. This has unlocked exciting new possibilities for our analytics teams across the business.

- Alex Edwards (Lead Data Analyst at Kraken)

Learn more

Dashboards as Code is now available for everybody to use. To get started, read the full guide in our docs.

Haven't tried Lightdash before? Book a demo to start a trial!