> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/d/databricks.md).

# Databricks

Databricks is a data and AI platform that runs workloads on clusters inside a workspace. OctoXLabs uses it to add the clusters, the workspace users with their groups, and the Databricks Apps of one workspace to the inventory.

## Use cases

* Find every asset that Databricks reports, so you can compare cluster inventory with other sources.

```
Adapters = databricks
```

* Find Databricks clusters that no other adapter has seen, which can point to unmanaged compute.

```
Adapters = databricks AND NOT Adapters = tenable-sc
```

* Review the users of the workspace and the groups they belong to, including members of the `admins` group.

```
Adapters = databricks
```

## Before you begin

### Network

| Source              | Destination                                      | Port | Protocol |
| ------------------- | ------------------------------------------------ | ---- | -------- |
| OctoXLabs connector | Databricks workspace host (the Domain you enter) | 443  | HTTPS    |

The connector always uses HTTPS and port 443. If the workspace is only reachable through a proxy, set the Proxy parameter.

### Required permissions

| Scope or role                                                                                            | Permission | Needed for                           |
| -------------------------------------------------------------------------------------------------------- | ---------- | ------------------------------------ |
| OAuth scope `all-apis` (service principal)                                                               | Read       | Token request, clusters, users, apps |
| Personal access token scopes `clusters`, `scim`, `apps` (only if you choose the "Other APIs" scope type) | Read       | Clusters, users, apps                |
| Workspace `admins` group membership (recommended for the service principal)                              | Read       | Workspace user list (admin-only API) |

{% hint style="info" %}
The adapter requests the `all-apis` scope and has not been verified with a scoped secret.
{% endhint %}

## Create credentials in Databricks

{% stepper %}
{% step %}

### Open the service principal

Click your username in the top bar of the workspace and select **Settings**. Open the **Identity and access** tab and click **Manage** next to **Service principals**. Select the service principal.
{% endstep %}

{% step %}

### Generate an OAuth secret

Open the **Secrets** tab and click **Generate secret**. Set a lifetime in days (at most 730). Under **Scopes**, select **all APIs**. Databricks marks this choice as not recommended, but the adapter requests the `all-apis` scope. Click **Generate**.
{% endstep %}

{% step %}

### Copy the client id and secret

Copy the secret and the client id (the application id of the service principal). The secret is shown only once.
{% endstep %}

{% step %}

### Or create a personal access token

Instead of OAuth, click your username, select **Settings** > **Developer**, click **Manage** next to **Access tokens**, then **Generate new token**. If you choose **Other APIs** as the scope type, add the `clusters`, `scim` and `apps` scopes. Databricks revokes a token that was not used for 90 days.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter              | Required                  | Type                    | Default  | Description                                                                                                                |
| ---------------------- | ------------------------- | ----------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------- |
| Domain                 | Yes                       | String                  | None     | Host name of the workspace URL, for example `dbc-a1b2345c-d6e7.cloud.databricks.com`. Do not include `https://` or a path. |
| Authentication type    | No                        | Choice: `oauth2`, `pat` | `oauth2` | How the adapter authenticates.                                                                                             |
| Client id              | Yes when type is `oauth2` | String                  | None     | Client id of the service principal.                                                                                        |
| Client secret          | Yes when type is `oauth2` | String                  | None     | OAuth secret of the service principal.                                                                                     |
| Personal access token  | Yes when type is `pat`    | String                  | None     | Databricks personal access token.                                                                                          |
| Fetch devices          | No                        | Boolean                 | `True`   | Collect clusters as devices.                                                                                               |
| Fetch users            | No                        | Boolean                 | `True`   | Collect workspace users.                                                                                                   |
| Fetch web applications | No                        | Boolean                 | `True`   | Collect Databricks Apps as web applications.                                                                               |
| Proxy                  | No                        | String                  | None     | Proxy address, used as `http://<proxy>`.                                                                                   |
| Timeout                | No                        | Integer (seconds)       | `30`     | Request timeout.                                                                                                           |

## Troubleshooting

| Error message                                    | Cause                                                      | Fix                                                                         |
| ------------------------------------------------ | ---------------------------------------------------------- | --------------------------------------------------------------------------- |
| `Databricks token response has no access_token.` | The token endpoint answered without a token.               | Check the client id and secret, and that the secret has the all APIs scope. |
| `<fields> required when auth_type is <type>.`    | A field needed by the chosen authentication type is empty. | Fill in client id and client secret for `oauth2`, or the token for `pat`.   |
| `Max retries exceeded for <url>`                 | Databricks kept answering HTTP 429.                        | Lower the load on the workspace and retry later.                            |

## Change history

{% hint style="info" %}
Available starting from version 6.9.1.
{% endhint %}
