# Snowflake

**URL:** https://heroiclabs.com/docs/satori/concepts/performance-monitoring/export-to-data-lakes/snowflake/
**Summary:** Configure and manage your Snowflake connection to Satori.
**Keywords:** snowflake, satori
**Categories:** satori, data-lakes, settings

---


# Connect to Snowflake

This page describes how to connect to Snowflake from Satori, enabling you to send data to your Snowflake instance for analysis.

## Prerequisites

Before you can connect to Snowflake, you must have the following:

* [Snowflake account](https://www.snowflake.com/en/)
* [Database created for Satori](#create-a-database)
* Snowflake account [user](#create-a-user) and [role](#create-a-role) with the appropriate permissions

{{< note "important" "Snowflake UI and CLI Access" >}}
Not all actions required can be performed via the Snowflake web interface, you'll also need to use the [Snowflake CLI](https://docs.snowflake.com/en/user-guide/snowsql).
{{< / note >}}

### Create a database

To create a database for Satori, navigate to your Snowflake instance dashboard and follow these steps:

1. From the left-hand navigation menu, go to **Data** > **Databases** and click **+ Database**:

{{< screenshot src="images/pages/satori/concepts/monitoring/monitoring_datalake-snowflake-databases.png" alt="Databases" >}}

2. In the displayed modal enter the name for your new database, `SatoriDB` in this example, and click **Create**.

### Create a user

To create a user for Satori, navigate to your Snowflake instance dashboard and follow these steps:

1. From the left-hand navigation menu, go to **Admin** > **Users & Roles** and select the **Users** tab.

2. Click **+ User** and in the displayed modal enter the details for your new user, `SatoriUser` in this example:

{{< screenshot src="images/pages/satori/concepts/monitoring/monitoring_datalake-create-user.png" alt="Create User" >}}

{{< note "important" "Advanced Settings" >}}
Don't select any **Default Role** or **Default Warehouse** in the **Advanced Settings** section.
{{< / note >}}

3. Click **Create User** to confirm the changes.

### Create a role

To create a role for Satori, navigate to your Snowflake instance dashboard and follow these steps:

1. From the left-hand navigation menu, go to **Admin** > **Users & Roles** and select the **Roles** tab:

{{< screenshot src="images/pages/satori/concepts/monitoring/monitoring_datalake-snowflake-users-roles.png" alt="Users & Roles" >}}

2. Click **+ Role** and in the displayed modal enter the name for your new role, `Satori` in this example:

{{< screenshot src="images/pages/satori/concepts/monitoring/monitoring_datalake-create-role.png" alt="Create Role" >}}

{{< note "important" "Granting Permissions" >}}
Don't grant any permissions at this time. Those configurations will be performed via the CLI.
{{< / note >}}

3. Click **Create** to confirm the changes.

### Grant permissions

To grant the appropriate permissions to the Satori user and role, follow these steps:

1. Login via SnowSQL using the `ACCOUNTADMIN` user:

```bash
sudo snowsql -a <account> -u <admin_user>
```

You're prompted for your `sudo` password and then your Snowflake password.

2. Use the `ACCOUNTADMIN` role:

```sql
USE ROLE ACCOUNTADMIN;
```

3. Grant the role created above to the Satori user created above:

```sql
GRANT ROLE SATORI TO USER SATORIUSER;
```

4. Grant the following database and schema permissions to the Satori role:

```sql
GRANT ALL ON ALL schemas in database SATORDIDB TO ROLE SATORI;
```

5. Grant the following table permissions to the Satori role:

```sql
GRANT ALL ON ALL TABLES IN SCHEMA PUBLIC TO ROLE SATORI;
GRANT ALL ON ALL TABLES IN SCHEMA SATORIDB.PUBLIC TO ROLE SATORI;
```

6. Grant the following warehouse permissions to the Satori role:

```sql
GRANT ALL ON ALL WAREHOUSE COMPUTE_WH TO ROLE SATORI;
```

7. Grant the following database usage permissions to the Satori role:

```sql
GRANT USAGE ON DATABASE SATORIDB TO ROLE SATORI;
```

{{< note "important" >}}
At this point, we recommend that you navigate to the Snowflake web interface and verify that the permissions have been granted correctly.
{{< / note >}}

8. From the Snowflake UI, navigate to **Admin** > **Users & Roles** > **Users**. For the `SATORIUSER`, use the options menu and select **Edit**:

{{< screenshot src="images/pages/satori/concepts/monitoring/monitoring_datalake-edit-user.png" alt="Edit User" >}}

9. In the displayed modal, set the **Default Role** to `SATORI` and the **Default Warehouse** to `COMPUTE_WH`.
   * Optionally, the warehouse may be specified as a query paramenter in the connection string.

10. Click **Save User** to confirm the changes.

## Configure Snowflake in Satori

From the Satori dashboard, navigate to **Settings** > **Data Lakes** > **Snowflake**:

1. Enter the corresponding details:
    * **Table Name**: The name of the table to which data will be sent, `SATORI` in this example.
    * **Snowflake URL**: The URL of your Snowflake instance in the format `user:password@<snowflakeAccount>/$DB_NAME/$SCHEMA?warehouse=$WAREHOUSE`. For example, `satoriuser:password@<snowflakeAccount>/SATORIDB/PUBLIC?warehouse=COMPUTE_WH`.
      * Snowflake query parameters can optionally be provided as well.

2. Click **Save** to save the configuration.

The Snowflake connection is now configured and will be tested by inserting a dummy event into the specified table. If the test is successful, the connection status will be displayed as **Active**.
