Skip to main content

Lightdash Preview

Developer previews are temporary Lightdash projects where you can safely experiment with your metrics, dimensions and charts without affecting your production project.

Run lightdash preview from inside your projectโ€‹

lightdash preview

Then cmd + click to open the preview link from your terminal. Once you're in Lightdash go to Explore --> Tables, then click on the model(s) you just updated to see your changes and play around with them.

Problems with credentials?

When you create developer previews, Lightdash will use the same warehouse connection settings you have in your profiles.yml file for your current dbt project. This can be a problem if you're using a local database that your laptop can reach but your Lightdash instance cannot.

Set up developer previews on your pull requestsโ€‹

If you've connected Lightdash to GitHub, you can setup a github action and get Lightdash to create new dynamic preview projects automatically when a new pull request is created, and it will automatically delete the preview project when the pull request is closed or merged.

Step 1: add the credentials to Github secretsโ€‹

We are going to add some secrets and config to GitHub actions, but you don't want those to be public , so the best way to do this is to add them as secrets on Github

Go to your repo, click on Settings , on the left sidebar, click on Secrets under Security. Now click on the New repository secret

We need the following credentials, you can find them on the app, or in your ~/.config/lightdash/config.yaml file on your machine if you have used the Lightdash CLI already.

LIGHTDASH_API_KEYโ€‹

Create a new personal access token, by going to Settings > Personal Access Tokens. This is the token you'll put in for LIGHTDASH_API_KEY.

LIGHTDASH_PROJECTโ€‹

The UUID for your project. For example, if your URL looks like https://eu1.lightdash.cloud/projects/3538ab33-dc90-aabb-bc00-e50bba3a5f69/tables, then 3538ab33-dc90-45f0-aabb-e50bba3a5f69 is your LIGHTDASH_PROJECT

LIGHTDASH_URLโ€‹

This is either https://eu1.lightdash.cloud or https://app.lightdash.cloud (check the URL to your Lightdash project)

DBT_PROFILESโ€‹

Copy your full profiles.yml file into this secret, like:

jaffle_shop:
target: dev
outputs:
dev:
type: snowflake
account: abcd
user: test
password: ****
role: SYSADMIN
database: database
warehouse: warehouse
schema: jaffle_shop

Step 2: Create start-preview.yml and close-preview.yml workflows in Githubโ€‹

Go to your repo, click on Actions menu, and click on Configure

Github actions page

Now copy this start-preview.yml file from our cli-actions repo

And save by clicking on Start commit

Do the same with this close-preview.yml file.

You're done!โ€‹

Everytime you create a new pull request , a new preview project with your branch name will be created on your organization. Everytime you make a change to that branch, the preview environment will get updated. Once you close or merge your pull request, the preview project will get deleted.

You can see the log on Github actions page

Github actions stop preview