|
1 | 1 | import BrowsingTheCatalog from "./assets/browsing-the-catalog.webp";
|
2 | 2 | import ExploringAMetric from "./assets/exploring-a-metric.png";
|
| 3 | +import VSCodeSchemaValidationExample from "./assets/vscode-schema-validation-example.png"; |
3 | 4 |
|
4 | 5 | # Spotlight
|
5 | 6 |
|
@@ -53,7 +54,193 @@ Visualize your metrics in the **Metrics Explorer**.
|
53 | 54 | - **'Another metric':** Compare to any other metric in the project **that has a default time dimension specified in the `.yml`**. This includes joins [See how](#configuring-default-time-settings-in-yml)
|
54 | 55 | 7. **Drag to zoom:** Click and drag across the chart to highlight the desired time range or data points, then release to zoom in on that segment. Hit ‘Reset Zoom’ to reset chart.
|
55 | 56 |
|
56 |
| -## Configuring default time settings in .yml |
| 57 | +## Curating Spotlight for your business users |
| 58 | + |
| 59 | +Spotlight is designed to be a tool for your business users to explore and understand your data. |
| 60 | + |
| 61 | +To make Spotlight more useful for your business users, you can curate the metrics they can see and explore. |
| 62 | + |
| 63 | +To do this, you can: |
| 64 | + |
| 65 | +- Control the visibility of metrics in the catalog |
| 66 | +- Add categories to your metrics |
| 67 | +- Add default time settings to your metrics |
| 68 | + |
| 69 | +All through your Lightdash `.yml` files. |
| 70 | + |
| 71 | +### Configuring global visibility of metrics |
| 72 | + |
| 73 | +You can control the visibility of metrics in the catalog by creating a new file called `lightdash.config.yml` in the root of your dbt project. |
| 74 | + |
| 75 | +See this video for an example on how to set this up: |
| 76 | + |
| 77 | +<div |
| 78 | + style={{ |
| 79 | + position: "relative", |
| 80 | + paddingBottom: "56.25%", |
| 81 | + height: "0", |
| 82 | + marginBottom: "40px", |
| 83 | + }} |
| 84 | +> |
| 85 | + <iframe |
| 86 | + src="https://www.loom.com/embed/6bf1c5115090413490bf93b1ada60c31?sid=d29adbd1-e62c-4e37-bfc5-d6f71b7b149c" |
| 87 | + frameborder="0" |
| 88 | + webkitallowfullscreen |
| 89 | + mozallowfullscreen |
| 90 | + allowfullscreen |
| 91 | + style={{ |
| 92 | + position: "absolute", |
| 93 | + top: 0, |
| 94 | + left: 0, |
| 95 | + width: "100%", |
| 96 | + height: "100%", |
| 97 | + }} |
| 98 | + ></iframe> |
| 99 | +</div> |
| 100 | + |
| 101 | +**Step-by-step guide** |
| 102 | + |
| 103 | +1. Add the following to your `lightdash.config.yml` file: |
| 104 | + |
| 105 | +```yml |
| 106 | +spotlight: |
| 107 | + default_visibility: show |
| 108 | +``` |
| 109 | +
|
| 110 | +:::info |
| 111 | +The default visibility can be set to `show` or `hide`. If you don't set this, the default visibility will be `show`, so all metrics will be visible in the catalog by default (but other settings like user attributes will still apply). |
| 112 | +::: |
| 113 | + |
| 114 | +This will set the default visibility of metrics in the catalog to `show` for all metrics in your project. You can also set this to `hide` if you prefer to hide metrics by default and then override this on a per-model/metric basis. |
| 115 | + |
| 116 | +2. Now that you've set the default visibility, you can override this on a per-model/metric basis. |
| 117 | + |
| 118 | +```yml |
| 119 | +models: |
| 120 | + - name: events |
| 121 | + meta: |
| 122 | + spotlight: |
| 123 | + visibility: hide |
| 124 | +``` |
| 125 | + |
| 126 | +This will hide the events model from the catalog. |
| 127 | + |
| 128 | +3. If there are metrics in the events model that you want to make visible, you can override the default visibility for those metrics. |
| 129 | + |
| 130 | +```yml |
| 131 | +models: |
| 132 | + - name: events |
| 133 | + meta: |
| 134 | + spotlight: |
| 135 | + visibility: hide |
| 136 | + metrics: |
| 137 | + - name: event_count |
| 138 | + type: count |
| 139 | + spotlight: |
| 140 | + visibility: show |
| 141 | +``` |
| 142 | + |
| 143 | +4. Once you compile your project, you'll see the `event_count` metric in the catalog, even though the events model is hidden. |
| 144 | + |
| 145 | +### Assigning categories to metrics |
| 146 | + |
| 147 | +Categories are a great way to organize your metrics in the catalog. You can create a new category by adding a new `categories` field to your `lightdash.config.yml` file. |
| 148 | + |
| 149 | +Here's a video showing how to set this up: |
| 150 | + |
| 151 | +<div |
| 152 | + style={{ |
| 153 | + position: "relative", |
| 154 | + paddingBottom: "56.25%", |
| 155 | + height: "0", |
| 156 | + marginBottom: "40px", |
| 157 | + }} |
| 158 | +> |
| 159 | + <iframe |
| 160 | + src="https://www.loom.com/embed/6ab64c402aa74c34a66da3e7664b6c99?sid=8410b682-2696-45b8-bca1-47b255c7457a" |
| 161 | + frameborder="0" |
| 162 | + webkitallowfullscreen |
| 163 | + mozallowfullscreen |
| 164 | + allowfullscreen |
| 165 | + style={{ |
| 166 | + position: "absolute", |
| 167 | + top: 0, |
| 168 | + left: 0, |
| 169 | + width: "100%", |
| 170 | + height: "100%", |
| 171 | + }} |
| 172 | + ></iframe> |
| 173 | +</div> |
| 174 | + |
| 175 | +**Step-by-step guide** |
| 176 | + |
| 177 | +1. Add the following to your `lightdash.config.yml` file: |
| 178 | + |
| 179 | +```yml |
| 180 | +spotlight: |
| 181 | + categories: |
| 182 | + revenue: # Required, this is the name of the category, and how it will be referenced in the catalog. It must be unique. |
| 183 | + label: Revenue # Required, this is what will be displayed in the catalog |
| 184 | + color: "orange" # Optional, defaults to "gray", with the option to choose from a range of colors: "gray", "violet", "red", "orange", "green", "blue", "indigo", "pink", "yellow" |
| 185 | +``` |
| 186 | + |
| 187 | +2. Now that you've added a category, you can assign metrics to it by adding a `categories` field to your models `.yml` file. |
| 188 | + |
| 189 | +```yml |
| 190 | +models: |
| 191 | + - name: events |
| 192 | + meta: |
| 193 | + spotlight: |
| 194 | + visibility: show |
| 195 | + categories: |
| 196 | + - revenue |
| 197 | +``` |
| 198 | + |
| 199 | +This will add the `revenue` category to all metrics in the events model. |
| 200 | + |
| 201 | +If you want to add another category to a specific metric, you can do so by adding the `categories` field to the metric's `.yml` file. And remember, you can only add categories that have been defined in the `lightdash.config.yml` file. |
| 202 | + |
| 203 | +3. Now you can add the `marketing` category to the `event_count` metric: |
| 204 | + So in your `lightdash.config.yml` file, you need to have another category. Let's call it `marketing` and add it to the `event_count` metric, like so: |
| 205 | + |
| 206 | +```yml |
| 207 | +spotlight: |
| 208 | + categories: |
| 209 | + marketing: |
| 210 | + label: Marketing |
| 211 | + color: "blue" |
| 212 | + revenue: |
| 213 | + label: Revenue |
| 214 | + color: "orange" |
| 215 | +``` |
| 216 | + |
| 217 | +Now you can add the `marketing` category to the `event_count` metric: |
| 218 | + |
| 219 | +```yml |
| 220 | +models: |
| 221 | + - name: events |
| 222 | + meta: |
| 223 | + spotlight: |
| 224 | + visibility: show |
| 225 | + categories: |
| 226 | + - revenue |
| 227 | + metrics: |
| 228 | + - name: event_count |
| 229 | + type: count |
| 230 | + spotlight: |
| 231 | + categories: |
| 232 | + - marketing |
| 233 | +``` |
| 234 | + |
| 235 | +In this example, the `event_count` metric will have both the `marketing` and `revenue` categories, it's cumulative. |
| 236 | + |
| 237 | +4. Once you compile your project, you'll see the `event_count` metric in the catalog with both the `marketing` and `revenue` categories and you can use this to filter your metrics in the catalog. |
| 238 | + |
| 239 | +:::info |
| 240 | +The categories you define need to be unique, so you can't have two categories with the same name. If you try to add a category with the same name as an existing category, you'll get an error. This error will be displayed in the UI and in the terminal (if you use the Lightdash CLI) when you compile your project. |
| 241 | +::: |
| 242 | + |
| 243 | +### Configuring default time settings in .yml |
57 | 244 |
|
58 | 245 | We recommend setting up default time fields to make it easier for your business users and save them time.
|
59 | 246 |
|
@@ -178,6 +365,44 @@ Not yet, but soon you'll be able to manage metadata directly in the UI and sync
|
178 | 365 | 2. **Metrics with a single time dimension:** Metrics from tables with only one time dimension will appear as it's assumed to be the most relevant.
|
179 | 366 | 3. **Metrics from joined tables:** Metrics from joined tables that meet the criteria in points 1 and 2 will also appear.
|
180 | 367 |
|
| 368 | +**e. How can I be sure that my yml changes are correct?** |
| 369 | + |
| 370 | +If you use VSCode, you can use our Lightdash schema validation to check your yml files are correct. |
| 371 | + |
| 372 | +1. Install this YAML extention for VSCode: https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml |
| 373 | +2. Open you user settings in JSON format and add the following: |
| 374 | + |
| 375 | +```json |
| 376 | +"[yaml]": { |
| 377 | + "editor.defaultFormatter": "redhat.vscode-yaml" |
| 378 | +}, |
| 379 | +"yaml.schemas": { |
| 380 | + "https://raw.githubusercontent.com/lightdash/lightdash/refs/heads/main/packages/common/src/schemas/json/lightdash-dbt-2.0.json": [ |
| 381 | + "*.yml", |
| 382 | + "/**/models/**/*.yml", |
| 383 | + "/**/models/**/*.yaml", |
| 384 | + "!lightdash.config.yml", |
| 385 | + "!dbt_project.yml" |
| 386 | + ], |
| 387 | + "https://raw.githubusercontent.com/lightdash/lightdash/refs/heads/main/packages/common/src/schemas/json/lightdash-project-config-1.0.json": [ |
| 388 | + "lightdash.config.yml" |
| 389 | + ] |
| 390 | +} |
| 391 | +``` |
| 392 | + |
| 393 | +This will add schema validation to your model yml files and your lightdash.config.yml file. |
| 394 | + |
| 395 | +3. Reload VSCode |
| 396 | + |
| 397 | +4. You'll see a red squiggly line under any errors in your yml files as well as suggestions for how to fix them and what is allowed. |
| 398 | + |
| 399 | +<img |
| 400 | + src={VSCodeSchemaValidationExample} |
| 401 | + width="400" |
| 402 | + height="200" |
| 403 | + style={{ display: "block", margin: "0 auto 20px auto" }} |
| 404 | +/> |
| 405 | + |
181 | 406 | ## Roles and permissions
|
182 | 407 |
|
183 | 408 | | **Action** | **Project Admin** | **Project Developer** | **Project Editor** | **Project Interactive Viewer** | **Project Viewer** |
|
|
0 commit comments