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

# Federation to ClickHouse setup guide

> Connect your ClickHouse to Propel for Federation.

<div />

This guide explains how to connect your own ClickHouse to Propel. It works with self-hosted, managed, or ClickHouse Cloud servers.

It covers how to:

1. [Create a user for Propel in your ClickHouse server](#step-1-create-a-user-for-propel-in-your-clickhouse-server).
2. [Make sure your ClickHouse is accessible from Propel IPs](##step-2-make-sure-your-clickhouse-is-accessible-from-propel-ips).
3. [Create a ClickHouse Data Pool in Propel](#step-3-create-a-clickhouse-data-pool-in-propel).
4. [Preview and query your data](#step-4-preview-and-query-your-data).

***

## Requirements

* You have a [Propel account](https://console.propeldata.com/get-started).
* You have a ClickHouse Cloud, self-managed, or managed ClickHouse server.
* A user with `SELECT` permission on the tables you need to connect.

***

## Step 1: Create a user for Propel in your ClickHouse server

In this section, you'll set up a user for Propel. Propel will use this user to connect to your ClickHouse instance and query the tables.

<Steps>
  <Step title="Create the role 'propel_role'">
    To create a role for Propel in ClickHouse, execute the SQL statement below.

    ```sql theme={"system"}
    CREATE ROLE propel_role;
    ```
  </Step>

  <Step title="Grant necessary permissions">
    Propel needs to be able to do a `SELECT` on the tables. You need to grant the "propel\_role" role `SELECT` privileges. You can limit this grant to only the tables you are going to connect to Propel by specifying each table name instead of the **"\*"**.

    ```sql theme={"system"}
    GRANT SELECT ON <DATABASE_NAME>.* TO propel_role;
    ```

    Replace `<DATABASE_NAME>` with your database name.
  </Step>

  <Step title="Create and assign the user">
    Create the user "propel\_user" and assign it the role "propel\_role". You can do this with the following SQL statements:

    ```sql theme={"system"}
    CREATE USER propel_user IDENTIFIED WITH sha256_password BY '<REPLACE_PASSWORD>';

    GRANT propel_role TO propel_user;
    ```

    Make sure to replace `<REPLACE_PASSWORD>` with a secure password.
  </Step>

  <Step title="Test the user">
    To ensure your user has the necessary permissions to see and query the tables you need, connect to your ClickHouse using the "propel\_user" you just created and run the following statements:

    ```sql theme={"system"}
    USE DATABASE <DATABASE_NAME>;
    SHOW TABLES;
    ```

    Make sure to replace `<DATABASE_NAME>` with a secure password. You should see the tables you need to connect to Propel.

    Make sure you can query the tables using a `SELECT` SQL statement.

    ```sql theme={"system"}
    SELECT * from <TABLE_NAME> LIMIT 10
    ```
  </Step>
</Steps>

If you see the records, you are good to go!

## Step 2. Make sure your ClickHouse is accessible from Propel IPs

To ensure that Propel can connect to your ClickHouse server, you need to authorize access from the following IP addresses:

```
18.219.73.236
3.15.73.135
3.17.239.162
```

### 2.1 Allowing Propel's IP in ClickHouse Cloud

If you are using ClickHouse Cloud, go to **"Settings"** then **"IP access list"** and click **"Add IPs"**.

<img src="https://mintcdn.com/propeldocs/hcO21NZvCQh4ySdA/images/changelog/2024-04-clickhouse-ips-01.png?fit=max&auto=format&n=hcO21NZvCQh4ySdA&q=85&s=181377d3672c8a8430a0e39d22cef633" alt="Screen capture of the ClickHouse Cloud Settings page" width="1261" height="879" data-path="images/changelog/2024-04-clickhouse-ips-01.png" />

Add the Propel IPs to the list.

<img src="https://mintcdn.com/propeldocs/hcO21NZvCQh4ySdA/images/changelog/2024-04-clickhouse-ips-02.png?fit=max&auto=format&n=hcO21NZvCQh4ySdA&q=85&s=745dc8ed6a89346a67d54c5ddba33b22" alt="Screen capture of the ClickHouse Cloud Add IPs page" width="424" height="421" data-path="images/changelog/2024-04-clickhouse-ips-02.png" />

## Step 3: Create a ClickHouse Data Pool in Propel

<Steps>
  <Step title="Go to Data Pools">
    A Propel Data Pool will represent a table in your ClickHouse server.

    Go to the **"Data Pools"** section of the Console and click **"Create Data Pool"**.

    <img src="https://mintcdn.com/propeldocs/hcO21NZvCQh4ySdA/images/changelog/2024-04-clickhouse-data-pool-01.png?fit=max&auto=format&n=hcO21NZvCQh4ySdA&q=85&s=57e5ae6602847cdefa49cc1f9bb7c981" alt="Propel Data Pool page" width="1671" height="875" data-path="images/changelog/2024-04-clickhouse-data-pool-01.png" />
  </Step>

  <Step title="Select ClickHouse">
    In the new Data Pool page, select **"ClickHouse"**.

    <img src="https://mintcdn.com/propeldocs/hcO21NZvCQh4ySdA/images/changelog/2024-04-clickhouse-data-pool-02.png?fit=max&auto=format&n=hcO21NZvCQh4ySdA&q=85&s=3a13f92760b3f68d358dce9e25bb62e9" alt="Propel new Data Pool page" width="1663" height="899" data-path="images/changelog/2024-04-clickhouse-data-pool-02.png" />
  </Step>

  <Step title="Add credentials">
    Select **"Add Credentials"**.

    <img src="https://mintcdn.com/propeldocs/hcO21NZvCQh4ySdA/images/changelog/2024-04-clickhouse-data-pool-03.png?fit=max&auto=format&n=hcO21NZvCQh4ySdA&q=85&s=05feb24fbd5b9fbe32cf2bae7fbca11c" alt="Propel add credentials page" width="1662" height="918" data-path="images/changelog/2024-04-clickhouse-data-pool-03.png" />

    Enter your ClickHouse connection details and click **"Test Credentials"**.

    <img src="https://mintcdn.com/propeldocs/hcO21NZvCQh4ySdA/images/changelog/2024-04-clickhouse-data-pool-04.png?fit=max&auto=format&n=hcO21NZvCQh4ySdA&q=85&s=baf203d3850e614fa46172be7db23e14" alt="Propel test credentials page" width="1658" height="915" data-path="images/changelog/2024-04-clickhouse-data-pool-04.png" />

    Wait until Propel connects and runs all the tests, then click **"Next"**.

    <img src="https://mintcdn.com/propeldocs/hcO21NZvCQh4ySdA/images/changelog/2024-04-clickhouse-data-pool-05.png?fit=max&auto=format&n=hcO21NZvCQh4ySdA&q=85&s=0fc5bb476b45a6d7eeec74a7dace527d" alt="Propel test credentials results page" width="862" height="546" data-path="images/changelog/2024-04-clickhouse-data-pool-05.png" />
  </Step>

  <Step title="Select tables">
    Check that Propel has access to all the tables you need, and click **"Continue"** to finish setting up your first ClickHouse Data Pool.

    <img src="https://mintcdn.com/propeldocs/hcO21NZvCQh4ySdA/images/changelog/2024-04-clickhouse-data-pool-06.png?fit=max&auto=format&n=hcO21NZvCQh4ySdA&q=85&s=29b6dfdd8b3e0561eb8af0433ed7e996" alt="Propel ClickHouse table list page" width="847" height="502" data-path="images/changelog/2024-04-clickhouse-data-pool-06.png" />

    Select the table and columns you want to connect to Propel and click **"Next"**.

    <img src="https://mintcdn.com/propeldocs/hcO21NZvCQh4ySdA/images/changelog/2024-04-clickhouse-data-pool-07.png?fit=max&auto=format&n=hcO21NZvCQh4ySdA&q=85&s=91e7036ef296362864804c3dc2a5009d" alt="Propel new ClickHouse Data Pool table selection" width="1667" height="914" data-path="images/changelog/2024-04-clickhouse-data-pool-07.png" />
  </Step>

  <Step title="Configure timestamp">
    Select the primary timestamp of the table and click **"Next"**.

    <img src="https://mintcdn.com/propeldocs/hcO21NZvCQh4ySdA/images/changelog/2024-04-clickhouse-data-pool-08.png?fit=max&auto=format&n=hcO21NZvCQh4ySdA&q=85&s=4078f8875aa7cb0a4deffac7dedd5211" alt="Propel new ClickHouse Data Pool timestamp selection" width="1662" height="911" data-path="images/changelog/2024-04-clickhouse-data-pool-08.png" />
  </Step>

  <Step title="Name your Data Pool">
    Give your Data Pool a name and a description, and click **"Create Data Pool"**.

    <img src="https://mintcdn.com/propeldocs/hcO21NZvCQh4ySdA/images/changelog/2024-04-clickhouse-data-pool-09.png?fit=max&auto=format&n=hcO21NZvCQh4ySdA&q=85&s=d7623498410073489c6dd9d422457c67" alt="Propel new ClickHouse Data Pool name and description" width="1671" height="917" data-path="images/changelog/2024-04-clickhouse-data-pool-09.png" />

    You should see the setup tasks completed successfully, and then you're all done!

    <img src="https://mintcdn.com/propeldocs/hcO21NZvCQh4ySdA/images/changelog/2024-04-clickhouse-data-pool-10.png?fit=max&auto=format&n=hcO21NZvCQh4ySdA&q=85&s=2ec4a441a3b4036cee0144dc9e09ee4a" alt="Propel new ClickHouse Data Pool setup tasks" width="1656" height="916" data-path="images/changelog/2024-04-clickhouse-data-pool-10.png" />
  </Step>
</Steps>

## Step 4: Preview and query your data

<Steps>
  <Step title="Preview your data">
    Click on the **"Preview Data"** tab.

    <img src="https://mintcdn.com/propeldocs/hcO21NZvCQh4ySdA/images/changelog/2024-04-clickhouse-data-pool-11.png?fit=max&auto=format&n=hcO21NZvCQh4ySdA&q=85&s=814f25541fd9d2f9974ce6b916545f2a" alt="Propel new ClickHouse Data Pool preview data" width="1652" height="918" data-path="images/changelog/2024-04-clickhouse-data-pool-11.png" />
  </Step>

  <Step title="Query with SQL">
    Click the **"Playground"** section and select **"SQL"** from the API dropdown.

    <img src="https://mintcdn.com/propeldocs/hcO21NZvCQh4ySdA/images/changelog/2024-04-clickhouse-data-pool-12.png?fit=max&auto=format&n=hcO21NZvCQh4ySdA&q=85&s=9eab8a1653c00898061689ea0ba29268" alt="Propel SQL Playground" width="1670" height="922" data-path="images/changelog/2024-04-clickhouse-data-pool-12.png" />
  </Step>

  <Step title="Query with GraphQL">
    Click the **"Playground"** section and select **"GraphQL"** from the API dropdown.

    <img src="https://mintcdn.com/propeldocs/hcO21NZvCQh4ySdA/images/changelog/2024-04-clickhouse-data-pool-13.png?fit=max&auto=format&n=hcO21NZvCQh4ySdA&q=85&s=bdbc021e8da7c86e1882848f039f3de1" alt="Propel GraphQL Playground" width="1674" height="923" data-path="images/changelog/2024-04-clickhouse-data-pool-13.png" />
  </Step>
</Steps>
