> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pelanor.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Snowflake

> Connect your Snowflake Data Warehouses to Pelanor to enable granular cost breakdowns per warehouse, database, table, query and user.

<Frame>
  <img src="https://mintcdn.com/pelanor-6a347cfc/pbyqhjH4Ga65EhJ5/images/snowflake-1.png?fit=max&auto=format&n=pbyqhjH4Ga65EhJ5&q=85&s=34fe8be337c1e34ea8899ffe5ec63f88" alt="Dashboard Image" width="1023" height="478" data-path="images/snowflake-1.png" />
</Frame>

***

## 1. Create a Pelanor Warehouse

<Steps>
  <Step title="Log in to Snowsight">
    Log in as an `ACCOUNTADMIN`.
  </Step>

  <Step title="Access Warehouses">
    Navigate to **Admin → Warehouses**.
  </Step>

  <Step title="Create a new warehouse">
    Click **+ Warehouse** in the top right.

    * **Name:** `PELANOR`
    * **Size:** X-Small
    * **Auto Suspend:** set to lowest available value
  </Step>
</Steps>

***

## 2. Set up Pelanor Integration

<Steps>
  <Step title="Access Dashboards">
    Navigate to **Projects → Dashboards**.
  </Step>

  <Step title="Create a dashboard">
    Click **+ Dashboard**

    * **Dashboard Name:** e.g., “Pelanor Integration”
  </Step>

  <Step title="Select warehouse">
    1. Click **No Warehouse Selected**
    2. Select `PELANOR` warehouse from the list
  </Step>

  <Step title="Create tile from SQL">
    Click **New Tile → From SQL Worksheet**
  </Step>
</Steps>

***

## Choose Your Authentication Mode

<Tabs>
  <Tab title="A. Password-Based Authentication">
    Run the following SQL, replacing `<SECURE PASSWORD PROVIDED DURING INSTALLATION>`:

    ```sql theme={null}
    use role accountadmin;
    create database pelanor;
    create role pelanor;
    create user pelanor;
    grant role pelanor to user pelanor;
    grant role pelanor to role accountadmin;
    grant all on warehouse pelanor to role pelanor;
    alter user pelanor set DEFAULT_WAREHOUSE=pelanor, DEFAULT_ROLE=pelanor;
    alter user pelanor set password '<SECURE PASSWORD PROVIDED DURING INSTALLATION>';

    -- Create views
    create view PELANOR.PUBLIC.QUERY_HISTORY as (
      select * from SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY
    );
    create view PELANOR.PUBLIC.WAREHOUSE_METERING_HISTORY as (
      select * from SNOWFLAKE.ORGANIZATION_USAGE.WAREHOUSE_METERING_HISTORY
    );
    create view PELANOR.PUBLIC.USAGE_IN_CURRENCY_DAILY as (
      select * from SNOWFLAKE.ORGANIZATION_USAGE.USAGE_IN_CURRENCY_DAILY
    );
    create view PELANOR.PUBLIC.TABLE_STORAGE_METRICS as (
      select * from SNOWFLAKE.ACCOUNT_USAGE.TABLE_STORAGE_METRICS
    );
    create view PELANOR.PUBLIC.DATABASE_STORAGE_USAGE_HISTORY as (
      select * from SNOWFLAKE.ORGANIZATION_USAGE.DATABASE_STORAGE_USAGE_HISTORY
    );
    create view PELANOR.PUBLIC.PIPES as (
      select * from SNOWFLAKE.ORGANIZATION_USAGE.PIPES
    );
    create view PELANOR.PUBLIC.PIPE_USAGE_HISTORY as (
      select * from SNOWFLAKE.ORGANIZATION_USAGE.PIPE_USAGE_HISTORY
    );
    create view PELANOR.PUBLIC.SEARCH_OPTIMIZATION_HISTORY as (
      select * from SNOWFLAKE.ACCOUNT_USAGE.SEARCH_OPTIMIZATION_HISTORY
    );

    grant usage on schema pelanor.public to role pelanor;
    grant usage on database pelanor to role pelanor;
    grant select on all views in schema pelanor.public to role pelanor;
    ```
  </Tab>

  <Tab title="B. Public-Private Key Authentication">
    1. Request the public key from Pelanor Support
    2. Run the SQL, replacing `<PUBLIC KEY PROVIDED BY PELANOR>`:

    ```sql theme={null}
    use role accountadmin;
    create database pelanor;
    create role pelanor;
    create user pelanor;
    grant role pelanor to user pelanor;
    grant role pelanor to role accountadmin;
    grant all on warehouse pelanor to role pelanor;
    alter user pelanor set DEFAULT_WAREHOUSE=pelanor, DEFAULT_ROLE=pelanor;
    alter user pelanor set rsa_public_key='<PUBLIC KEY PROVIDED BY PELANOR>';

    -- same view definitions and grants as in Password-based method
    ```
  </Tab>
</Tabs>

***

## 3. Validation

Run the following to test setup:

```sql theme={null}
use role pelanor;
select * from pelanor.public.query_history limit 1;
```

You should see at least one row. If not, recheck your configuration.

***

## 4. Retrieve Snowflake IDs

### Account ID

* **GUI:** Profile → **About / Account**
* **SQL:**
  ```sql theme={null}
  select current_account();
  ```

### Organization ID

* Run:
  ```sql theme={null}
  select distinct ORGANIZATION_NAME
  from SNOWFLAKE.ORGANIZATION_USAGE.WAREHOUSE_METERING_HISTORY;
  ```

<Warning>
  Do <strong>not</strong> confuse the "account locator" with the Account ID.
</Warning>

***

## 5. Send to Pelanor

Provide the following to your Pelanor contact:

* **Snowflake Organization ID**
* **Snowflake Account ID**
* **Database Parameters** (if changed):
  * warehouse (default: `PELANOR`)
  * database (default: `pelanor`)
  * schema (default: `PUBLIC`)
  * user (default: `pelanor`)
  * role (default: `pelanor`)
