Command-line interface for managing dbt projects and integrating with Lightdash
Download and upload Lightdash charts and dashboards as YAML files for version control and team collaboration.
Downloads charts and dashboards from Lightdash as YAML files (Lightdash Code).
lightdash download [options]Options:
Content Selection:
-c, --charts <charts...> - Chart slugs, UUIDs, or URLs to download (default: all charts, space-separated)-d, --dashboards <dashboards...> - Dashboard slugs, UUIDs, or URLs to download (default: all dashboards, space-separated)Download Configuration:
-p, --path <path> - Custom download path (default: ./lightdash)--nested - Use nested folder structure by project/space (default: false, flat structure)-l, --language-map - Generate language translation maps (default: false)--project <project uuid> - Project UUID to download from (overrides active project)--verbose - Enable debug logging (default: false)Usage Examples:
# Download all charts and dashboards (flat structure)
lightdash download
# Download to custom path
lightdash download --path ./my-lightdash-code
# Download with nested folder structure
lightdash download --nested
# Download specific charts by slug
lightdash download --charts monthly-revenue customer-segmentation
# Download specific dashboards by slug
lightdash download --dashboards executive-dashboard sales-overview
# Download both specific charts and dashboards
lightdash download --charts revenue-chart --dashboards exec-dashboard
# Download by UUID
lightdash download --charts abc-123-def-456
# Download by URL
lightdash download --charts https://app.lightdash.cloud/saved/abc-123
# Download with language translation maps
lightdash download --language-map
# Download from specific project
lightdash download --project abc-123-def-456
# Download with verbose output
lightdash download --verboseID Formats Supported:
my-chart-nameabc-123-def-456https://app.lightdash.cloud/saved/abc-123Uploads charts and dashboards from YAML files to Lightdash.
lightdash upload [options]Options:
Content Selection:
-c, --charts <charts...> - Chart slugs to force upload (default: uploads all, space-separated)-d, --dashboards <dashboards...> - Dashboard slugs to force upload (default: uploads all, space-separated)Upload Configuration:
-p, --path <path> - Custom path to upload from (default: ./lightdash)--force - Force upload even if content hasn't changed (default: false)--project <project uuid> - Project UUID to upload to (overrides active project)--verbose - Enable debug logging (default: false)Space Management:
--skip-space-create - Don't create spaces if missing (default: false, creates spaces)--public - Create new spaces as public (default: false, creates private spaces)Dashboard Options:
--include-charts - Include chart updates when uploading dashboards (default: false)Usage Examples:
# Upload all charts and dashboards from default path
lightdash upload
# Upload from custom path
lightdash upload --path ./my-lightdash-code
# Force upload all (ignore change detection)
lightdash upload --force
# Upload specific charts by slug
lightdash upload --charts monthly-revenue customer-segmentation
# Upload specific dashboards by slug
lightdash upload --dashboards executive-dashboard
# Upload both specific charts and dashboards
lightdash upload --charts revenue --dashboards executive
# Upload to specific project
lightdash upload --project abc-123-def-456
# Upload without creating missing spaces
lightdash upload --skip-space-create
# Upload and create spaces as public
lightdash upload --public
# Upload dashboards and their charts
lightdash upload --dashboards exec-dashboard --include-charts
# Upload with verbose output
lightdash upload --verboselightdash downloadCreates:
./lightdash/
├── charts/
│ ├── monthly-revenue.yml
│ ├── customer-segmentation.yml
│ └── order-analysis.yml
└── dashboards/
├── executive-dashboard.yml
└── sales-overview.ymlCharacteristics:
charts/ directorydashboards/ directoryUse when:
lightdash download --nestedCreates:
./lightdash/
├── charts/
│ ├── Sales Space/
│ │ ├── monthly-revenue.yml
│ │ └── customer-segmentation.yml
│ └── Finance Space/
│ └── payment-analysis.yml
└── dashboards/
├── Executive/
│ └── executive-dashboard.yml
└── Sales/
└── sales-overview.ymlCharacteristics:
Use when:
version: 1
name: Monthly Revenue
slug: monthly-revenue
space: Sales Space
description: Track monthly revenue trends
updatedAt: '2024-01-15T10:30:00Z'
updatedBy: user@example.com
metricQuery:
exploreName: orders
dimensions:
- orders_order_date_month
metrics:
- orders_total_revenue
filters:
dimensions:
- id: orders_status
target:
fieldId: orders_status
operator: equals
values:
- completed
sorts:
- fieldId: orders_order_date_month
descending: false
limit: 100
chartConfig:
type: cartesian
config:
layout:
xField: orders_order_date_month
yField:
- orders_total_revenue
eChartsConfig:
series:
- type: barversion: 1
name: Executive Dashboard
slug: executive-dashboard
space: Executive
description: Key business metrics at a glance
updatedAt: '2024-01-15T10:30:00Z'
updatedBy: user@example.com
tiles:
- uuid: tile-1
type: saved_chart
properties:
savedChartUuid: monthly-revenue-uuid
title: Monthly Revenue
x: 0
y: 0
h: 4
w: 6
- uuid: tile-2
type: saved_chart
properties:
savedChartUuid: customer-count-uuid
title: Total Customers
x: 6
y: 0
h: 4
w: 6
filters:
dimensions:
- id: date_range
target:
fieldId: orders_order_date
operator: inThePast
values:
- 90
settings:
unitOfTime: daysDownload everything for version control:
# Download all content
lightdash download --nested
# Commit to git
git add lightdash/
git commit -m "Snapshot Lightdash content"
git pushDownload specific items:
# Download specific chart
lightdash download --charts monthly-revenue
# Download multiple dashboards
lightdash download --dashboards exec-dashboard sales-dashboardSync changes from Lightdash:
# Re-download to get latest changes
lightdash download --force
# Review changes
git diff lightdash/
# Commit if desired
git add lightdash/
git commit -m "Update Lightdash content"Edit downloaded YAML files:
# Edit chart configuration
vim lightdash/charts/monthly-revenue.yml
# Edit dashboard layout
vim lightdash/dashboards/executive-dashboard.yml# Upload all changes
lightdash upload
# Or upload specific files
lightdash upload --charts monthly-revenue# Create feature branch
git checkout -b update-dashboard
# Modify YAML files
vim lightdash/dashboards/executive-dashboard.yml
# Commit changes
git add lightdash/
git commit -m "Update executive dashboard layout"
# Push and create PR
git push origin update-dashboard
# After review, upload to Lightdash
lightdash upload --dashboards executive-dashboardUpload automatically detects changes:
lightdash upload
# Output: No changes detected, skipping upload# Modify chart YAML
vim lightdash/charts/revenue.yml
# Upload detects changes
lightdash upload
# Output: Uploading 1 changed chart...Override change detection:
# Upload even if no changes detected
lightdash upload --forceUse when:
By default, upload creates missing spaces:
# If "Sales Space" doesn't exist, it's created
lightdash upload --charts sales-chartFail if space doesn't exist:
# Error if space missing
lightdash upload --skip-space-createUse when:
Control visibility of newly created spaces:
# Create spaces as private (default)
lightdash upload
# Create spaces as public
lightdash upload --publicPrivate spaces:
Public spaces:
Generate translation files for internationalization:
lightdash download --language-mapCreates additional files:
./lightdash/
├── charts/
│ ├── monthly-revenue.yml
│ └── monthly-revenue.i18n.yml # Translation map
└── dashboards/
├── executive-dashboard.yml
└── executive-dashboard.i18n.yml # Translation mapTranslation map format:
translations:
en:
name: Monthly Revenue
description: Track monthly revenue trends
es:
name: Ingresos Mensuales
description: Seguimiento de tendencias de ingresos mensuales
fr:
name: Revenus Mensuels
description: Suivi des tendances des revenus mensuelsUse when:
# Upload dashboard only
lightdash upload --dashboards executive-dashboard
# Charts referenced by dashboard are NOT updated# Upload dashboard AND its charts
lightdash upload --dashboards executive-dashboard --include-chartsUse when:
Multiple ways to specify charts/dashboards:
lightdash download --charts monthly-revenue
lightdash upload --charts monthly-revenueAdvantages:
lightdash download --charts abc-123-def-456Use when:
lightdash download --charts https://app.lightdash.cloud/saved/abc-123Use when:
name: Backup Lightdash Content
on:
schedule:
- cron: '0 2 * * *' # Daily at 2 AM
jobs:
backup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Lightdash CLI
run: npm install -g @lightdash/cli
- name: Download Content
env:
LIGHTDASH_API_KEY: ${{ secrets.LIGHTDASH_API_KEY }}
LIGHTDASH_PROJECT: ${{ secrets.LIGHTDASH_PROJECT }}
CI: true
run: lightdash download --nested
- name: Commit Changes
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add lightdash/
git diff --quiet && git diff --staged --quiet || git commit -m "Backup Lightdash content"
git pushname: Deploy Lightdash Content
on:
push:
branches: [main]
paths:
- 'lightdash/**'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Lightdash CLI
run: npm install -g @lightdash/cli
- name: Upload Content
env:
LIGHTDASH_API_KEY: ${{ secrets.LIGHTDASH_API_KEY }}
LIGHTDASH_PROJECT: ${{ secrets.LIGHTDASH_PROJECT }}
CI: true
run: lightdash uploadTrack chart and dashboard changes:
# Initial download
lightdash download --nested
git add lightdash/
git commit -m "Initial Lightdash snapshot"
# Make changes in UI
# Re-download
lightdash download --nested
git diff lightdash/
git commit -m "Updated revenue chart"Share chart configurations:
# Developer A: Create chart
lightdash download --charts new-feature-chart
git add lightdash/charts/new-feature-chart.yml
git commit -m "Add new feature chart"
git push
# Developer B: Pull and upload
git pull
lightdash upload --charts new-feature-chartMove content between environments:
# Download from dev
export LIGHTDASH_PROJECT="dev-project-uuid"
lightdash download --nested --path ./dev-content
# Upload to staging
export LIGHTDASH_PROJECT="staging-project-uuid"
lightdash upload --path ./dev-content
# Upload to production
export LIGHTDASH_PROJECT="prod-project-uuid"
lightdash upload --path ./dev-contentRegular backups:
# Automated backup script
#!/bin/bash
DATE=$(date +%Y%m%d)
lightdash download --path ./backups/lightdash-$DATE
tar -czf lightdash-backup-$DATE.tar.gz ./backups/lightdash-$DATERecovery:
# Restore from backup
tar -xzf lightdash-backup-20240115.tar.gz
lightdash upload --path ./backups/lightdash-20240115 --forceReview changes before applying:
# Download changes from UI
lightdash download
# Review diffs
git diff lightdash/
# If approved, commit
git add lightdash/
git commit -m "Approved dashboard updates"
# If not approved, discard
git checkout lightdash/Programmatically modify content:
# Download all
lightdash download --nested
# Modify with script
python scripts/update-chart-colors.py lightdash/charts/
# Upload changes
lightdash upload --forceRequired permissions:
Required permissions:
Error if insufficient permissions:
ForbiddenError: You don't have permission to modify this projectExit Code 0: Command succeeded Exit Code 1: Command failed
Success Output (Download):
✓ Downloaded 25 charts
✓ Downloaded 5 dashboards
✓ Files saved to ./lightdashSuccess Output (Upload):
✓ Uploaded 3 changed charts
✓ Uploaded 1 changed dashboard
✓ Created 1 spaceError: "Failed to download content"
--verbose for detailsError: "Failed to upload content"
Error: "Invalid YAML format"
lightdash lint --path lightdash/Error: "Space not found"
--skip-space-create=false to createError: "Chart not found"
Error: "Path not found"
lightdash download --nested
# Better organization
# Easier to navigate# Always version control
lightdash download --nested
git add lightdash/
git commit -m "Snapshot Lightdash content"git commit -m "Update revenue chart to include Q4 data"
git commit -m "Fix dashboard layout for mobile"
git commit -m "Add new customer segmentation chart"# Download current state
lightdash download
# Review changes
git diff lightdash/
# Upload if approved
lightdash upload# Regular downloads
# Store in version control
# Archive periodically# Upload to preview first
export LIGHTDASH_PROJECT="preview-uuid"
lightdash upload
# Validate
lightdash validate --only charts dashboards
# If good, upload to production
export LIGHTDASH_PROJECT="prod-uuid"
lightdash upload# Validate YAML before uploading
lightdash lint --path lightdash/
# Fix any errors
# Then upload
lightdash upload# CHANGELOG.md
## 2024-01-15
- Updated monthly revenue chart to use new metric
- Fixed executive dashboard layout
- Added customer segmentation chart to sales spaceInstall with Tessl CLI
npx tessl i tessl/npm-lightdash--cli