How to Connect Grafana to ClickHouse

Connecting a Grafana server to ClickHouse and

Once Grafana has been installed with the ClickHouse plugins, dashboards and charts can be created that draw off of data in the CLickHouse server.

Connecting Grafana to ClickHouse

Creating a Dashboard and Chart from ClickHouse data requires the creation of a Grafana Data Source. This is a configuration that specifies the ClickHouse server hostname and other settings Grafana will use to connect.

These instructions assume that you have installed Grafana with the ClickHouse plugins. For more information, see How to Install Grafana and ClickHouse Plugins.

Create Grafana Data Source with the ClickHouse Plugin

To create a new Grafana Data Source connected to a ClickHouse server:

  1. Connect to your Grafana server from a browser.

  2. From the left navigation panel, select Settings -> Data sources.

  3. Select Add Data Source.

    Select Data Source
  4. From the list of data sources, select ClickHouse.

    Select connection type ClickHouse.

Localhost Sample Data Source

For organizations who want to test their Grafana ClickHouse plugin with their own internal ClickHouse server, the following settings would be used to connect to a ClickHouse server at host name localhost, with no credentials and no encryption.

  1. Enter the following:
    1. Name: The name for the connection. This does not need to be the name of the ClickHouse server or database.
    2. URL: For localhost, we need to specify both the protocol and the port. In this case, it will be http://localhost:8123.
    3. Auth: Only required if a ClickHouse username and password are specified. If there are no ClickHouse credentials to use, then leave this section disabled.
    4. Additional:
      1. Use Post method to send queries: True
      2. Default database: Select the database to be used without having to specify it in connections.
  2. Select Save & test.
Localhost Data Source

If successful, then the Grafana server can connect to the ClickHouse server on localhost.

Altinity.Cloud Sample Data Source

The following samples are based on a publicly available ClickHouse sample database provided by Altinity.Cloud. This database provides access to US airline flight data and sample logs, and can be access through the following credentials:

  1. Enter the following:
    1. Name: The name for the connection. This does not need to be the name of the ClickHouse server or database.

    2. URL: The URL is in the format {HTTP/HTTPS}://{URL}:{port}. If using Altinity.Cloud, this is provided through the Cluster Access Point.

      Sample Data Source

      For example:

      If the connection is on the specific IP 192.168.0.10 in your network on an unencrypted link then the URL would be http://192.168.0.10:8123.

      If using the Altinity.Cloud example above then the URL would be https://github.demo.trial.altinity.cloud:8443. The URL used for Grafana breaks down as follows:

      1. connectiontype: HTTP or HTTPS
      2. url: The fully qualified domain name or IP address of the ClickHouse server.
      3. port: The port being used. By default, HTTP is port 8123, HTTPS is port 8443.
    3. Auth: Only required if a ClickHouse username and password are specified.

      1. Basic auth: True
      2. With Credentials: True
    4. Basic Auth Details: Only required if Basic auth is set to True.

      1. User: The ClickHouse username.
      2. Password: The ClickHouse user password.
    5. Additional:

      1. Use Post method to send queries: True
      2. Default database: Select the database to be used without having to specify it in connections.
  2. Select Save & test.

If the Save & test is successful, then the data source is available for use.

Last modified 2021.07.12: Grafana updates before final submission.