# Visualize ClickHouse® data with Grafana®

You can visualise your ClickHouse® data using Grafana® and Exoscale can help you connect the two services.

## Prerequisites

1.  [Exoscale CLI](/reference/cli/exo/) version 1.97 or later. Earlier releases expose no
    ClickHouse commands at all, and the commands on this page fail as unknown commands.
1.  Managed ClickHouse® service accessible by HTTPS
1.  Managed Grafana service (see how to
    [get started with Managed Grafana](/product/dbaas/service-specific/grafana/))

## Variables

You\'ll need a few variables for the setup.

| Variable                 | Description                                   |
| ------------------------ | --------------------------------------------- |
| `CLICKHOUSE_HOST`        | Hostname of your ClickHouse service.          |
| `CLICKHOUSE_NATIVE_PORT` | Port of the native protocol endpoint, read from the `clickhouse` component. |
| `CLICKHOUSE_HTTPS_URI`   | HTTPS service URI of your ClickHouse service, in the form `https://CLICKHOUSE_HOST:PORT`, where `PORT` is read from the `clickhouse_https` component. |
| `CLICKHOUSE_USER`        | Username to access ClickHouse service.        |
| `CLICKHOUSE_PASSWORD`    | Password to access ClickHouse service.        |

Read the host and the ports from the service components: the native protocol port from the
`clickhouse` entry, and the HTTPS port from the `clickhouse_https` entry. Ports are assigned per
service, so read them from your own service rather than reusing a value from an example:

```bash
exo x get-dbaas-service-clickhouse my-clickhouse -z ch-gva-2 -q 'components'
```

Retrieve the password of the `avnadmin` user:

```bash
exo x reveal-dbaas-clickhouse-user-password my-clickhouse avnadmin -z ch-gva-2
```

## Integrate ClickHouse® with Grafana®

Managed Grafana ships with two ClickHouse data source plugins: the official **ClickHouse** plugin
by Grafana Labs, and the **Altinity plugin for ClickHouse**. Both work with Managed ClickHouse®.

### With the official ClickHouse plugin

1.  Log in to your [Managed Grafana®](/product/dbaas/service-specific/grafana/) service.
1.  From the left menu, select **Connections** > **Data sources** > **Add new data source**.
1.  Find **ClickHouse** in the list and select it.
1.  Set **Server address** to `CLICKHOUSE_HOST` and **Server port** to
    `CLICKHOUSE_NATIVE_PORT`.
1.  Enable **Secure connection**, and set the protocol to **Native**.
1.  Set your `CLICKHOUSE_USER` and `CLICKHOUSE_PASSWORD` in the credentials fields.
1.  Select **Save & test**. Grafana reports that the data source is working.

### With the Altinity plugin

1.  From the left menu, select **Connections** > **Data sources** > **Add new data source**.
1.  Find **Altinity plugin for ClickHouse** in the list and select it.
1.  Set **URL** to `CLICKHOUSE_HTTPS_URI`.
1.  In **Auth** section, enable **Basic auth** and **With Credentials**.
1.  In **Basic Auth Details**, set your `CLICKHOUSE_USER` and
    `CLICKHOUSE_PASSWORD`.
1.  Select **Save & test**.

Now you can create a dashboard and panels to work with the data from
your Managed ClickHouse® service.

