Integrating Grafana

Connecting Grafana to your Altinity.Cloud environment

Grafana is a popular open-source observability platform for monitoring applications and infrastructure. We’ll look at connecting Altinity.Cloud to Grafana Cloud, although connecting to any Grafana instance works basically the same.

To connect your ClickHouse cluster to Grafana, you’ll need the connection details for your cluster. In the Clusters view, click the Connection Details link:

Getting connection details for the cluster

Figure 1 - A cluster panel

You’ll need the host name and the HTTP port:

Getting connection details for the cluster

Figure 2 - Connection details for the ClickHouse cluster

With those details, go ahead and log in to your Grafana Cloud account. Click the Grafana menu in the upper left corner, then select the Data sources item in the Connections section:

Connect a data source

Figure 3 - The create new data source menu

On the Data sources page, click the + Add new data source button in the upper right:

Connect a data source

Figur 4 - The Add new data source button

On the Add data source page, type click in the search bar, then click on the Altinity plugin for ClickHouse item:

Connect a data source

Figure 5 - Selecting the Altinity plugin for ClickHouse

To start, give your new data source a name at the top of the panel:

Connect a data source

Figure 6 - Naming your new data source

In the HTTP section of the page, enter https:// followed by the host and HTTP port from the ACM Connection Details page:

HTTP details for the new data source

Figure 7 - Entering the connection data for your ClickHouse cluster

Scroll down to the Auth section, select Basic auth, then enter your user ID and password:

Credentials for the new data source

Figure 8 - Entering the credentials for your ClickHouse cluster

NOTE: The user ID is the ID of your ClickHouse cluster, which is probably not the same as the ID of your Altinity.Cloud account. (admin is the default.)

To complete the connection, scroll to the bottom of the page and click the Save & test button:

Save and test the new data source

Figure 9 - The Save & Test button

If all goes well, you’ll get a Data source is working message from Grafana:

New data source is working

Figure 10 - A successfully created data source

If anything goes wrong, the dialog will contain an error message:

Connection to new data source failed

Figure 11 - An unsuccessfully created data source

From the Data source is working message, you can take either the Building a dashboard or the Explore view link. We’ll look at the Explore view; if you want to build a dashboard, you’ll use the Explore view to define a query against your ClickHouse cluster.

The Explore view starts with an empty query:

Connection to new data source failed

Figure 12 - The initial data source explorer view

The data source you just created is displayed at the top of the panel. Click the –database– and –table– fields to see a list of all of the tables and database available:

Connection to new data source failed

Figure 13 - Selecting a database

Here we’re selecting the system database. Clicking the –table– field displays all of the tables in the system database:

Connection to new data source failed

Figure 14 - Selecting a table within a database

We’ll select the query_log table. With the database and table selected, click the Go to Query button:

Connection to new data source failed

Figure 15 - The Go to Query button

You’ll see the query source and a graph of the results:

Connection to new data source failed

Figure 16 - The syntax of the query and its results