Skip to content

Commit 92e6acb

Browse files
authored
update connection page and dbt project reference (#85)
* update connection page and dbt project reference * fix typo in nav * fix links
1 parent 0474280 commit 92e6acb

File tree

9 files changed

+182
-545
lines changed

9 files changed

+182
-545
lines changed

docs.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
{
6969
"group": "Exploring Data in Lightdash",
7070
"pages": [
71-
"guides/ai-analyst",
71+
"guides/ai-agents",
7272
"guides/metrics-catalog",
7373
"guides/limiting-data-using-filters",
7474
"guides/interactive-dashboards",
@@ -170,7 +170,7 @@
170170
"references/filters",
171171
"references/table-calculations",
172172
"references/custom-fields",
173-
"references/custom-tooltips",
173+
"references/custom-tooltip",
174174
"references/custom-charts"
175175
]
176176
},

get-started/setup-lightdash/connect-project.mdx

Lines changed: 132 additions & 327 deletions
Large diffs are not rendered by default.
Binary file not shown.
287 KB
Loading
331 KB
Loading
330 KB
Loading

images/references/dbt-refresh.png

131 KB
Loading

references/dbt-projects.mdx

Lines changed: 48 additions & 216 deletions
Original file line numberDiff line numberDiff line change
@@ -4,271 +4,103 @@ description: "You can easily make changes in dbt and see them updated in your Li
44
---
55

66
<Info>
7-
8-
Lightdash supports dbt v1.4.0 and above. If you are using an older version of dbt, you will need to upgrade to sync your project to Lightdash
9-
7+
Lightdash supports dbt v1.4.0 and above. If you are using an older version of dbt, you will need to upgrade to sync your project to Lightdash
108
</Info>
119

12-
## 1. Automatically: deploy your changes to Lightdash using a GitHub action
13-
14-
If you've connected Lightdash to GitHub, you can setup a `github action` and get Lightdash to deploy your project automatically. This is the easiest way to keep Lightdash in sync with your changes in dbt.
15-
16-
### Step 1: add the credentials to Github secrets
1710

18-
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.
11+
## Syncing your dbt project to Lightdash
1912

20-
<Info>
21-
22-
If you already have a GitHub action for Lightdash, then you can use the same Lightdash secrets you created for your other action.
23-
</Info>
13+
You can sync your dbt project code with Lightdash in a few different ways. We recommend everyone set up continuous deployment, but you can also refresh in the Lightdash app or deploy from the CLI.
2414

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

27-
<Frame>
28-
![](/images/references/github-secrets-fc35152c7ebb768974b385a0e2601dc5.jpg)
29-
</Frame>
16+
### 1. Set up continous deployment
3017

18+
[Read how to do that and check out our example workflow files](/guides/cli/how-to-use-lightdash-deploy#automatically-deploy-your-changes-to-lightdash-using-a-github-action).
3119

32-
We need to add the following secrets:
3320

34-
##### `LIGHTDASH_API_KEY`
21+
### 2. Click "Refresh dbt" in Lightdash
3522

36-
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`.
23+
The button can be found on the Query from tables page.
3724

3825
<Frame>
39-
<img src="/images/references/personal-access-token-9ed8a8c2b16edc5ee745c4909d4093d3.png"/>
26+
![screenshot-refresh-dbt](/images/references/dbt-refresh.png)
4027
</Frame>
4128

42-
##### `LIGHTDASH_PROJECT`
43-
44-
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`
29+
_If you're using a git connection (like GitHub, Gitlab or Bitbucket), you'll need to push + merge your changes to the branch that your Lightdash project is connected to before you press `Refresh dbt`._
4530

46-
##### `LIGHTDASH_URL`
31+
<Info>
32+
If you've made any changes to the underlying data (for example, adding a new column in your `model.sql` file or changing the SQL logic of a dimension), then you need to run: `dbt run -m yourmodel` before you click `Refresh dbt` in Lightdash.
33+
</Info>
4734

48-
This is either `https://eu1.lightdash.cloud` or `https://app.lightdash.cloud` for Lightdash Cloud users (check the URL to your Lightdash project). If you self-host, this should be your own custom domain.
4935

50-
##### `DBT_PROFILES`
36+
### 3. Push code from the CLI
5137

52-
Some tips for this bit:
38+
If you're using the [Lightdash CLI](/guides/cli/how-to-install-the-lightdash-cli), you can use `lightdash deploy` to deploy your changes to Lightdash. [Read more about how to use `lightdash deploy`](/guides/cli/how-to-use-lightdash-deploy).
5339

54-
* You might be able to copy a bunch of the information from your local `profiles.yml` file. You can see what's in there by typing `cat ~/.dbt/profiles.yml` in your terminal.
55-
* If you have a separate `prod` and `dev` profile, you probably want to use the information from your `prod` profile for your GitHub action.
56-
* If you want to have different connection settings depending on the user that opened the pull request (dev profiles), then [check out this guide](/guides/cli/how-to-use-lightdash-preview#how-to-use-the-developer-credentials-in-your-preview-project).
40+
<Warning>
41+
We don't recommend using `lightdash deploy` from your local environment as the primary way you update Lightdash since small mistakes can lead to production issues.
42+
</Warning>
5743

58-
Find your data warehouse from the list below to get a profiles.yml file template. Fill out this template, and this is your `DBT_PROFILES` secret.
5944

60-
<AccordionGroup>
61-
<Accordion title="BigQuery">
62-
BigQuery OAuth:
45+
## dbt project settings
6346

64-
Step 1: create a secret called `GOOGLE_APPLICATION_CREDENTIALS`
47+
For more information about dbt connection types (Github, Gitlab, Bitbucket, etc.) and the fields required for each type, [read the dbt project section in our connection guide](/get-started/setup-lightdash/connect-project#2-import-a-dbt-project).
6548

66-
Add the service account credentials (the JSON file) that you want to use for your GitHub action. It should look something like this:
49+
Below are details about the univeral fields for all connected dbt projects.
6750

68-
```json
69-
{
70-
"type": "service_account",
71-
"project_id": "jaffle_shop",
72-
"private_key_id": "12345",
73-
"private_key": "-----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY-----\n",
74-
"client_email": "jaffle_shop@jaffle_shop.iam.gserviceaccount.com",
75-
"client_id": "12345",
76-
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
77-
"token_uri": "https://oauth2.googleapis.com/token",
78-
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
79-
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/jaffle_shop"
80-
}
8151

82-
```
52+
### Target name
8353

84-
Step 2: create another secret called `DBT_PROFILES`
54+
**Target** contains information about your dbt connection to your warehouse.
8555

86-
Copy-paste this template into the secret and fill out the details.
56+
It's the dataset or schema in your data warehouse that Lightdash will look for your dbt models. By default, we set this to be the same value as you have as the default in your `profiles.yml` file when you run `lightdash deploy` (if that's how you created or recently deployed your project).
8757

88-
This will always use this project connection in your GitHub actions. If you want your preview projects to have different connection settings depending on the user that opened the pull request (dev profiles), then see what you need to add to your secret [in this guide](/guides/cli/how-to-use-lightdash-preview#how-to-use-the-developer-credentials-in-your-preview-project).
58+
If you want to update this, you can enter the target of your choice in the project settings (for example `prod` or `analytics`.)
8959

90-
```yaml
91-
[my-bigquery-db]: # this is the name of your project
92-
target: dev
93-
outputs:
94-
dev:
95-
type: bigquery
96-
method: oauth
97-
keyfile: keyfile.json # no need to change this! We'll automatically use the keyfile you created in the last step.
98-
project: [GCP project id]
99-
dataset: [the name of your dbt dataset]
60+
[Read more about dbt targets in the dbt docs.](https://docs.getdbt.com/reference/dbt-jinja-functions/target)
10061

101-
```
10262

103-
More info in dbt's profiles docs: [https://docs.getdbt.com/reference/warehouse-profiles/bigquery-profile#service-account-file](https://docs.getdbt.com/reference/warehouse-profiles/bigquery-profile#service-account-file)
63+
### dbt selector
10464

105-
</Accordion>
65+
You can filter out models in your dbt project that you don't want to see in Lightdash. This is useful if you have a large
66+
dbt project and you want to speed up the sync process. Unlike [table selection](/guides/adding-tables-to-lightdash#limiting-the-tables-in-lightdash-using-dbt-tags), this selector is applied to the dbt models, so it will skip the entire compilation process for the models that you don't want to see in Lightdash.
10667

107-
<Accordion title="Postgres">
108-
Postgres profile configuration:
68+
To do this, you can add a **dbt selector** to your project settings. This is a JSON object that contains the models you want to include in Lightdash.
10969

110-
```yaml
111-
company-name:
112-
target: dev
113-
outputs:
114-
dev:
115-
type: postgres
116-
host: [hostname]
117-
user: [username]
118-
password: [password]
119-
port: [port]
120-
dbname: [database name]
121-
schema: [dbt schema]
122-
threads: [1 or more]
123-
keepalives_idle: 0
124-
connect_timeout: 10
125-
retries: 1
70+
For example, if you only want to include the `my_model` and all models with the `lightdash` tag in Lightdash, you can add the following to your dbt project settings:
12671

72+
```console
73+
my_model tag:lightdash
12774
```
12875

129-
More info in dbt's profiles docs: [https://docs.getdbt.com/reference/warehouse-profiles/postgres-profile#profile-configuration](https://docs.getdbt.com/reference/warehouse-profiles/postgres-profile#profile-configuration)
130-
131-
This will always use this project connection in your GitHub actions. If you want your preview projects to have different connection settings depending on the user that opened the pull request (dev profiles), then see what you need to add to your secret [in this guide](/guides/cli/how-to-use-lightdash-preview#how-to-use-the-developer-credentials-in-your-preview-project).
132-
</Accordion>
76+
We support all dbt selectors. [Read more about selectors in the dbt docs](https://docs.getdbt.com/reference/node-selection/syntax#combining-state-and-result-selectors).
13377

13478

135-
<Accordion title="Redshift">
136-
Redshift password-based authentication:
79+
### Environment variables
13780

138-
```yaml
139-
company-name:
140-
target: dev
141-
outputs:
142-
dev:
143-
type: redshift
144-
host: [hostname.region.redshift.amazonaws.com]
145-
user: [username]
146-
password: [password]
147-
port: 5439
148-
dbname: analytics
149-
schema: analytics
150-
threads: 4
151-
keepalives_idle: 240
152-
connect_timeout: 10
153-
ra3_node: true # enables cross-database sources
154-
155-
```
81+
If you've used [environment variables in your dbt `profiles.yml` file](https://docs.getdbt.com/reference/dbt-jinja-functions/env%5Fvar), you can add these to Lightdash here.
15682

157-
More info in dbt's profiles docs: [https://docs.getdbt.com/reference/warehouse-profiles/redshift-profile#password-based-authentication](https://docs.getdbt.com/reference/warehouse-profiles/redshift-profile#password-based-authentication)
83+
For each environment variable, you'll need to add the `key` + `value` pair for the item.
15884

159-
This will always use this project connection in your GitHub actions. If you want your preview projects to have different connection settings depending on the user that opened the pull request (dev profiles), then see what you need to add to your secret [in this guide](/guides/cli/how-to-use-lightdash-preview#how-to-use-the-developer-credentials-in-your-preview-project).
160-
</Accordion>
85+
You'll normally find these values in a file called `.env` in your dbt project directory.
16186

162-
<Accordion title="Snowflake">
163-
User / Private Key authentication:
87+
For example, I might have something like:
16488

16589
```yaml
166-
my-snowflake-db:
167-
target: dev
90+
profile:
91+
target: prod
16892
outputs:
169-
dev:
170-
type: snowflake
171-
account: [account id]
172-
173-
# User/private_key auth
174-
private_key_path: [path/to/private.key]
175-
private_key_passphrase: [passphrase for the private key, if key is encrypted]
176-
177-
role: [user role]
178-
database: [database name]
179-
warehouse: [warehouse name]
180-
schema: [dbt schema]
181-
threads: [1 or more]
182-
client_session_keep_alive: False
183-
query_tag: [anything]
184-
93+
prod:
94+
type: postgres
95+
host: 127.0.0.1
96+
user: "{{ env_var('DBT_USER') }}"
97+
....
18598
```
18699

187-
More info in dbt's profiles docs: [https://docs.getdbt.com/docs/core/connect-data-platform/snowflake-setup#key-pair-authentication](https://docs.getdbt.com/docs/core/connect-data-platform/snowflake-setup#key-pair-authentication)
188-
189-
This will always use this project connection in your GitHub actions. If you want your preview projects to have different connection settings depending on the user that opened the pull request (dev profiles), then see what you need to add to your secret [in this guide](/guides/cli/how-to-use-lightdash-preview#how-to-use-the-developer-credentials-in-your-preview-project).
190-
</Accordion>
191-
192-
193-
<Accordion title="DataBricks">
194-
Set up a DataBricks target:
100+
Then a `.env` file like:
195101

196102
```yaml
197-
your_profile_name:
198-
target: dev
199-
outputs:
200-
dev:
201-
type: databricks
202-
catalog:
203-
[
204-
optional catalog name,
205-
if you are using Unity Catalog,
206-
only available in dbt-databricks>=1.1.1,
207-
]
208-
schema: [schema name]
209-
host: [yourorg.databrickshost.com]
210-
http_path: [/sql/your/http/path]
211-
token: [dapiXXXXXXXXXXXXXXXXXXXXXXX] # Personal Access Token (PAT)
212-
threads: [1 or more]
213-
103+
export DBT_USER="myspecialuserkey123"
214104
```
215105

216-
More info in dbt's profiles docs: [https://docs.getdbt.com/reference/warehouse-profiles/bigquery-profile#service-account-json](https://docs.getdbt.com/reference/warehouse-profiles/bigquery-profile#service-account-json)
217-
218-
This will always use this project connection in your GitHub actions. If you want your preview projects to have different connection settings depending on the user that opened the pull request (dev profiles), then see what you need to add to your secret [in this guide](/guides/cli/how-to-use-lightdash-preview#how-to-use-the-developer-credentials-in-your-preview-project).
219-
220-
</Accordion>
221-
</AccordionGroup>
222-
223-
224-
### Step 2: Create deploy.yml workflow in Github
225-
226-
Go to your repo, click on `Actions` menu.
227-
228-
If you don't have any GitHub actions, you'll just need to click on `Configure`
229-
230-
<Frame>
231-
![Github actions page](/images/references/github-actions-f74f88aa1b1413a111be7dbf16d65d53.png)
232-
</Frame>
233-
234-
If you have some GitHub actions in your repo already, click on `New workflow`, then select `setup a workflow yourself`.
235-
236-
<Frame>
237-
![](/images/references/new-workflow-existing-actions-e321bd117d93bf139a01424d3771d0e6.jpg)
238-
</Frame>
239-
240-
Now copy [this file](https://github.com/lightdash/cli-actions/blob/main/deploy.yml) from our [cli-actions](https://github.com/lightdash/cli-actions) repo.
241-
242-
Give it a nice name like `deploy-lightdash.yml`
243-
244-
And commit this to your repo by clicking on `Start commit`.
245-
246-
### You're done!
247-
248-
Everytime you make a change to your repo, on the `main` branch, it will automatically deploy your new config into your Lightdash projects
249-
250-
You can see the log on the `Github actions` page
251-
252-
<Frame>
253-
![](/images/references/github-run-e24152442d7002253f6fd6dc66a9a24e.png)
254-
</Frame>
255-
256-
## 2. In the UI: Syncing your dbt changes using `refresh dbt`
257-
258-
Whenever you make changes to your YAML files, you can sync Lightdash and see these changes by clicking the `refresh dbt` button in the Explore view of the app.
259-
260-
<Frame>
261-
![screenshot-refresh-dbt](/images/references/screenshot-refresh-dbt-3b6ee58ee347b0b10cd89aacf09e3abf.png)
262-
</Frame>
263-
264-
If you're using a git connection (like GitHub, Gitlab or Bitbucket), you'll need to push + merge your changes to the branch that your Lightdash project is connected to before you run `refresh dbt`.
265-
266-
## 3. From the command line: Syncing your dbt changes using `lightdash deploy`
267-
268-
If you're using the [Lightdash CLI](/guides/cli/how-to-install-the-lightdash-cli), you can use the `lightdash deploy` command to deploy your changes to your Lightdash project.
269-
270-
To read more about how to use `lightdash deploy`, [check out our docs](/guides/cli/how-to-use-lightdash-deploy).
271-
272-
## Note: If you've made any changes to the underlying data, you need to run dbt first
273-
274-
If you've made any changes to the underlying data (for example, adding a new column in your `model.sql` file or changing the SQL logic of an existing dimension), then you need to run: `dbt run -m yourmodel` before you click `refresh dbt` in Lightdash.
106+
So, in Lightdash, I'd add a new environment variable and put `key` as `DBT_USER` and `value` as `myspecialuserkey123`.

0 commit comments

Comments
 (0)