> For the complete documentation index, see [llms.txt](https://docs.lightbeam.ai/lxqobxw6ak7CTnsQjikH/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lightbeam.ai/lxqobxw6ak7CTnsQjikH/core-features/spectra-ai/data-sources/databases-and-datalakes/databricks.md).

# Databricks

Connecting Databricks to LightBeam

***

## Overview

LightBeam Spectra users can connect various data sources to the LightBeam application and these data sources will be continuously monitored for PII, PHI data.

**Example**: AWS Glue, Looker, DynamoDB, Redshift, etc.

### About Databricks

Databricks is a platform used for a variety of tasks ranging from data warehousing, BI, ML etc.

A workspace is what that will be onboarded with Lightbeam. We find sensitive data present in Databricks that are managed by the Unity catalog. Users can onboard a workspace with a list of Catalogs/Databases and Lightbeam will scan all the tables inside those Catalogs/Databases.

We expect a SQL warehouse enabled inside the workspace which we will use to execute SQL queries to sample data from each table.

### Features

#### Datasource Registration &#x20;

Databricks admins can create a service principal with restricted user permissions and use a personal access token for that service principal for registration. Users will be provided a list of SQL warehouses present in the workspace. They need to select one workspace. The users will be provided a list of catalogs and databases, they can filter catalogs/databases that they wish to scan.

**Metadata Scanning**

We scan the tables present in the Unity catalog configured in scan conditions. For each table, we get the list of columns part of the table, their data types etc. We also fetch row count, size of the table if they are available.

#### PII Detection

For PII detection, we need sample data for all the columns for a table. We use SQL warehouse configured during datasource registration for executing SQL queries for sampling data from tables. For reading data, we sample 5000 rows for each table.&#x20;

***

## Onboarding Databricks Data Source

1. Login to your LightBeam Instance.<br>
2. Click on **DATASOURCES** on the Top Navigation Bar.<br>
3. Click on **“Add a data source”.**

<figure><img src="https://682442409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0FnJiPbEPpkm5U4tiZUM%2Fuploads%2Fo0IEhucQ9N5hycB13AaA%2FScreenshot%202024-08-30%20at%203.45.14%20PM.png?alt=media&amp;token=94dec2e4-8853-457a-95f0-828194616490" alt="" width="188"><figcaption><p>Figure 1. Add a datasource</p></figcaption></figure>

4. Search for **Databricks**.<br>

<figure><img src="https://682442409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0FnJiPbEPpkm5U4tiZUM%2Fuploads%2FvIHVnYJgXiVobvej4DaE%2FScreenshot%202024-08-30%20at%203.32.41%20PM.png?alt=media&amp;token=03dfeda2-2534-4512-8a59-5372a6548c2d" alt="" width="375"><figcaption><p>Figure 2. Databricks datasource</p></figcaption></figure>

5. Click on **Databricks.**
6. Fill in the details as shown below and click **Next**:

<figure><img src="https://682442409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0FnJiPbEPpkm5U4tiZUM%2Fuploads%2FOkfa3S2bybdu12pwD3Fz%2FScreenshot%202024-08-30%20at%203.33.01%20PM.png?alt=media&amp;token=e3342b26-e9a6-4304-9a67-ca18c8da5fd8" alt=""><figcaption><p>Figure 3. Datasource configuration</p></figcaption></figure>

#### Basic Information

* **Instance Name:** This is the unique name given to the data source.
* **Description:** This is an optional field needed to describe the use of this data source.
* **Primary Owner:** Email address of the person responsible for this data source which will get alerts by default.
* **Source of Truth:** LightBeam Spectra would have monitored data sources that contain data acting as a single point of truth and that can be used for looking up entities/attributes that help to identify if the other attributes/entities found in any other data source are accurate or not. A Source of Truth data set would create entities based on the attributes found in the data.
* **Location:** The location of the data source.
* **Purpose:** The purpose of the data being collected/processed.
* **Stage**: The stage of the data source. **Example**: Source, Processing, Archival, etc.<br>

7\. In this step, insert the credentials as shown below and click **Test Connection** –

<figure><img src="https://682442409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0FnJiPbEPpkm5U4tiZUM%2Fuploads%2F6mYjdNSxIH468vbs6X2g%2FScreenshot%202024-08-30%20at%203.33.33%20PM.png?alt=media&amp;token=6653ce73-13cc-4a7b-9206-96cafc1a9c91" alt="" width="375"><figcaption><p>Figure 4. Datasource credentials</p></figcaption></figure>

8. Verify that you get the message Test Connection **Success** on the screen. Click on **Next**.&#x20;
9. After this select a warehouse from the drop down list.&#x20;

<figure><img src="https://682442409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0FnJiPbEPpkm5U4tiZUM%2Fuploads%2FyvXBRikV55h6zXIxlxPf%2FScreenshot%202024-08-30%20at%203.42.21%20PM.png?alt=media&amp;token=b91a4d7b-60f4-4a47-b60d-93242f5e927a" alt=""><figcaption><p>Figure 5. Select a SQL Warehouse</p></figcaption></figure>

10. In the next step, you will see a list of catalogs from dropdown presented. Select catalogs that you wish to scan.<br>

<figure><img src="https://682442409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0FnJiPbEPpkm5U4tiZUM%2Fuploads%2FJpDAwqHxnALsEbyxxfZj%2FScreenshot%202024-08-30%20at%203.42.28%20PM.png?alt=media&amp;token=d915d940-4d72-4886-8c01-cc0028d9032c" alt="" width="375"><figcaption><p>Figure 6. Select Catalogs</p></figcaption></figure>

11. By default, all databases part of a catalog will be scanned. If you wish to remove any database from scan conditions, you can do it too.

<figure><img src="https://682442409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0FnJiPbEPpkm5U4tiZUM%2Fuploads%2F36SPRymjknRBVukPG0xx%2FScreenshot%202024-08-30%20at%203.42.44%20PM.png?alt=media&amp;token=fbccf615-163a-448a-bc91-c977bb553421" alt="" width="375"><figcaption><p>Figure 7. Filter databases from a Catalog.</p></figcaption></figure>

Please verify that all databases selected for scanning show up in the list of databases. Ensure you've made your desired selections before connecting the data source.<br>

12. Finally, click on **Start Sampling** to connect to the Databricks data source.

***

## APPENDIX

### Minimal permissions setup&#x20;

This guide outlines the process to create a service account or a user with minimal permissions necessary for integrating Databricks with LightBeam. Either of the option A or B can be followed.

#### A. Using On-behalf token for Service Account

1. Go to Databricks account management console → user management → service principal. Add a new service principal

<figure><img src="https://682442409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0FnJiPbEPpkm5U4tiZUM%2Fuploads%2F7TLvv7HwfJZKyRGitcnr%2Fimage.png?alt=media&amp;token=7ba41e97-8a76-46af-a939-f8431d1c527d" alt="" width="375"><figcaption><p>Figure 8. Create a service principal</p></figcaption></figure>

2. Go to the workspace you want to onboard to Lightbeam by clicking on Open on right side of workspace list.<br>

   <figure><img src="https://682442409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0FnJiPbEPpkm5U4tiZUM%2Fuploads%2Faibfit71wFCCcbABYJG8%2Fimage.png?alt=media&amp;token=b7f6cee7-8fd2-4927-9a0e-de2188e9b03e" alt="" width="375"><figcaption><p>Figure 9. Databricks Workspace</p></figcaption></figure>
3. Add this newly created service principal to the workspace that you are onboarding with lightbeam. From the workspace console, go to top right side username of account → Settings → Identity and access → Add service Principal.<br>

   <figure><img src="https://682442409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0FnJiPbEPpkm5U4tiZUM%2Fuploads%2FOilWpiMeqQqJuD7SWQ4d%2Fimage.png?alt=media&amp;token=3062950a-5823-4bde-83d4-11dc476d2f26" alt="" width="375"><figcaption><p>Figure 10. Databricks Workspace</p></figcaption></figure>
4. Give this service principal access to use SQL warehouse.<br>

   <figure><img src="https://682442409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0FnJiPbEPpkm5U4tiZUM%2Fuploads%2FNK4Dtb3WwwbxU3uMAqNe%2Fimage.png?alt=media&amp;token=9b342df2-704c-44f3-be11-1c5645353f1b" alt="" width="335"><figcaption><p>Figure 11. Add service principal to workspace</p></figcaption></figure>
5. Go to the catalog tab on left side and click on the catalogs you want to onboard with Lightbeam and click on grant.<br>

   <figure><img src="https://682442409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0FnJiPbEPpkm5U4tiZUM%2Fuploads%2F2uQvPipwTdCUndPY1H5A%2Fimage.png?alt=media&amp;token=9f58ce82-22ca-4fc0-acff-4cbac5c36e65" alt="" width="375"><figcaption><p>Figure 12. Databricks Catalogs</p></figcaption></figure>
6. Now give this service principal SELECT, USECATALOG and USESCHEMA access to the catalogs that you wish to scan inside the workspace.

<figure><img src="https://682442409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0FnJiPbEPpkm5U4tiZUM%2Fuploads%2FvtB81HFY3BQVJ8fReTMZ%2Fimage.png?alt=media&amp;token=f2824099-da11-4009-866b-4aeaa2c5020f" alt="" width="375"><figcaption><p>Figure 13.  Catalog Permissions</p></figcaption></figure>

7. Give this service principal access to use Personal Access Token. Go to Admin Settings → Advanced → Access Control → Personal Access Token -> Permission settings. Grant Can Use permission to this service principal. \
   \
   If you get error like \
   Token permissions can be set only if at least one token has been created in the workspace. \
   \
   Then\
   Go the workspace -> Click on profile picture -> settings -> Under user section click on Developer -> Access tokens -> manage, create a new access token.<br>

   <figure><img src="https://682442409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0FnJiPbEPpkm5U4tiZUM%2Fuploads%2FgVKJiF0hkjZUe4lviO8v%2Fimage.png?alt=media&amp;token=3f2e1ca1-aab0-4bc8-93c2-4230881961b9" alt="" width="375"><figcaption><p>Figure 14. Token permissions</p></figcaption></figure>
8. Install Databricks CLI using following documentation <https://docs.databricks.com/en/dev-tools/cli/install.html#homebrew-install>.
9. Configure Databricks CLI
   1. Run `databricks auth login –host <URL of the workspace>`
   2. It will open the login page in browser, input the credentials to complete login.
10. Finally from Databricks CLI, generate a personal access token for this service principal.Copy application ID for this service principal from Admin Settings → Identity and access → Service Principals. Keep lifetime seconds 31536000 (1 year) so that the token doesn’t expire soon.<br>

    `databricks token-management create-obo-token <application_id> --lifetime-seconds <lifetime_seconds>`
11. Copy the token\_value from the response. This will be used for onboarding Databricks with Lightbeam.<br>

#### B.  Using PAT (Personal Access Token)

1. Add a new user to the workspace that you are onboarding with lightbeam. From the workspace console, go to Top right side username of account → Settings → Identity and access → Add User.

<figure><img src="https://682442409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0FnJiPbEPpkm5U4tiZUM%2Fuploads%2FOkMDZGQkDPO56XnlWRfR%2FScreenshot%202025-01-27%20at%203.24.53%E2%80%AFPM.png?alt=media&amp;token=f84f8255-92d7-4229-80f0-1ea12c3b4aa4" alt="" width="375"><figcaption><p>Figure 15. Add a New User</p></figcaption></figure>

2. Here, an existing user can be used or a new user can be onboarded.&#x20;
   1. If an existing user is to be used search for it and select it.

<figure><img src="https://682442409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0FnJiPbEPpkm5U4tiZUM%2Fuploads%2F1If4KWSFz0Vm6xX9C5je%2FScreenshot%202025-03-06%20at%2010.30.39%20AM.png?alt=media&amp;token=46c6d939-7abe-4fda-90fe-53bba79e70d9" alt="" width="375"><figcaption><p>Figure 16. Search for an existing user</p></figcaption></figure>

&#x20;        b. Enter email address of new user to be added.

<figure><img src="https://682442409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0FnJiPbEPpkm5U4tiZUM%2Fuploads%2FAOYFle6bR9SlNfXeTfWv%2FScreenshot%202025-03-06%20at%2010.30.54%20AM.png?alt=media&amp;token=b31abdd3-8adb-4c44-b8a3-c041b7b34ad6" alt="" width="375"><figcaption><p>Figure 17. Add email of the new user.</p></figcaption></figure>

3. After user is added, go to the catalog tab on left side and click on the catalogs you want to onboard with Lightbeam, go to permissions tab and click on grant.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfip8R3TfYHSr_rOBiW0UHk9_kHcbU5durm6dicG3UhhCynluXaDUkxNy3IdNd7OXc5hKf15ixNqQRjI8PmzDDBfSw0jmqwXekfK27EjKfXhXaHqPwmEwC2r5RCSFDhSNZsorDE5okkeZR9RUhW3SfgK3uw?key=fMRgPbnRtOl7G2mkzEXXOw" alt="" width="375"><figcaption><p>Figure 18. Databricks Catalogs</p></figcaption></figure>

4. Now give this added user SELECT, USECATALOG and USESCHEMA access to the catalogs that you wish to scan inside the workspace.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfkQb6KEk5qE2Q_H2aq0pP-L1bALhwjPZkUSy5kjBw6FIT0iukPTf7lTjgRZUWf_FS2scOYn1BN0mwGsutCCfuOj2Rcrkm_evmhjIJJaifLCftWOyRA3HUwDtWPD5lsewt3WW-uTN3cSH2MpaJPfFsD0Sp0?key=fMRgPbnRtOl7G2mkzEXXOw" alt="" width="375"><figcaption><p>Figure 19. Catalog Permissions</p></figcaption></figure>

5. Give this User access to use Personal Access Token. Go to Admin Settings → Advanced → Access Control → Personal Access Token -> Permission settings. Grant Can Use permission to User and  service principal.

&#x20;       If you get error like

&#x20;       Token permissions can be set only if at least one token has been created in             &#x20;

&#x20;       the workspace.

&#x20;       Then

&#x20;       Go the workspace -> Click on profile picture -> settings -> Under user section  &#x20;

&#x20;       click on Developer -> Access tokens -> manage, create a new access token.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfDajxycJLphX7u8qTMKB07hJ8elAW9AAPGySYibT7f8cUilxwxwQ1UpoV638xuj5q-IMax2jvQ6UXgo_W2zVle_oL0I2UOL8Y9eDyMc4ItqP51AwzwzwVj2e8T0rcKeHWTJruk7Qqu9DSVEPgkRY0OMJBC?key=fMRgPbnRtOl7G2mkzEXXOw" alt="" width="375"><figcaption><p>Figure 20. Token Permission</p></figcaption></figure>

6. Now login the with added user email and create Personal Access Token. Go to workspace -> Click on profile picture -> settings -> Under user section click on Developer -> Access tokens -> manage, create a new access token.

<figure><img src="https://682442409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0FnJiPbEPpkm5U4tiZUM%2Fuploads%2FiTAIPqRwT4Hc0LbMxQji%2Fimage.png?alt=media&amp;token=085c32e9-7af1-48c5-b1db-c8239f565a1a" alt="" width="375"><figcaption><p>Figure 21. Create PAT for user</p></figcaption></figure>

7. Copy the token\_value. This will be used for onboarding Databricks with Lightbeam.<br>

**Validate permissions to the datasource.**

Next, the user needs to validate these permissions to the datasource. This ensures authorized access to the datasource by the credentials provided by the user. After validating the permissions to the datasource, the user can onboard Databricks in Lightbeam.

#### Steps

1. First, clone the repository [`https://github.com/lightbeamai/lb-installer`](https://github.com/lightbeamai/lb-installer)
2. Go into `sql_user_check_databricks` directory
3. Please refer to the **`README.md`** file in the directory for detailed instructions.

***

## About LightBeam

LightBeam automates Privacy, Security, and AI Governance, so businesses can accelerate their growth in new markets. Leveraging generative AI, LightBeam has rapidly gained customers’ trust by pioneering a unique *privacy-centric* and *automation-first* approach to security. Unlike siloed solutions, LightBeam ties together sensitive data cataloging, control, and compliance across structured and unstructured data applications providing 360-visibility, redaction, self-service DSRs, and automated ROPA reporting ensuring ultimate protection against ransomware and accidental exposures while meeting data privacy obligations efficiently. \
\
LightBeam is on a mission to create a secure privacy-first world helping customers automate compliance against a patchwork of existing and emerging regulations.

For any questions or suggestions, please get in touch with us at: <support@lightbeam.ai>.<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.lightbeam.ai/lxqobxw6ak7CTnsQjikH/core-features/spectra-ai/data-sources/databases-and-datalakes/databricks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
