Перейти к основному содержимому
Перейти к основному содержимому

Looker Studio

Community Maintained

Looker Studio может подключаться к ClickHouse через интерфейс MySQL, используя официальный источник данных MySQL от Google.

Настройка ClickHouse Cloud

Select Connect your app

After creating your ClickHouse Cloud Service, on the Connect your app screen, select MySQL from the drop down.

ClickHouse Cloud credentials screen showing MySQL interface selection dropdown

Enable the MySQL interface

Toggle the switch to enable the MySQL interface for this specific service. This will expose port 3306 for this service and prompt you with a MySQL connection screen that includes your unique MySQL username.

ClickHouse Cloud MySQL interface enabling toggle and connection details

Alternatively, in order to enable the MySQL interface for an existing service:

Select Connect

Ensure your service is in Running state then click on the service you want to enable the MySQL interface for. Select "Connect" from the left menu:

ClickHouse Cloud service connection screen with Connect option highlighted

Choose MySQL

Select MySQL from the Connect With drop down.

ClickHouse Cloud connection screen showing MySQL option selection

Enable the MySQL interface

Toggle the switch to enable the MySQL interface for this specific service. This will expose port 3306 for this service and prompt you with your MySQL connection screen that include your unique MySQL username.

ClickHouse Cloud connection screen with MySQL interface enabled showing connection details

Creating a readonly MySQL user in ClickHouse Cloud

ClickHouse Cloud automatically creates a mysql4<subdomain> user that shares the same password as the default user. The <subdomain> portion corresponds to the first part of your ClickHouse Cloud hostname.

This username format is required for compatibility with tools that establish secure connections but don't include SNI (Server Name Indication) data in their TLS handshake. Without SNI information, the system cannot perform proper internal routing, so the subdomain hint embedded in the username provides the necessary routing information. The MySQL console client is an example of a tool that requires this.

подсказка

A recommended best practice is to create a new readonly MySQL user.

примечание

For a ClickHouse Cloud hostname like foobar.us-east1.aws.clickhouse.cloud, the <subdomain> part equals to foobar, and a custom MySQL username could look like mysql4foobar_team1.

Create a readonly settings profile

Create a settings profile to apply to your readonly user, setting the readonly setting to 1:

Create a new readonly MySQL user

Create a user with a name following this format:

Apply the readonly_profile to the new user and make sure that the password is in double SHA1 format. For example:

Grant the new user permissions to access the desired tables

Grant the new user the necessary permissions to interact with the desired tables or databases. For example, if you want to grant access to system.query_log only:

примечание

For the readonly user, make sure to only grant SELECT permissions to the tables you want to access.

The newly created user can be used to connect to your ClickHouse Cloud service with the MySQL interface.

Troubleshooting multiple MySQL users in ClickHouse Cloud

If you created a new MySQL user, and you see the following error while connecting via MySQL CLI client:

In this case, ensure that the username follows the mysql4<subdomain>_<username> format, as described (above).

Настройка локального сервера ClickHouse

Please refer to the official documentation on how to set up a ClickHouse server with enabled MySQL interface.

Aside from adding an entry to the server's config.xml

it is also required to use Double SHA1 password encryption for the user that will be using MySQL interface.

Generating a random password encrypted with Double SHA1 from the shell:

The output should look like the following:

The first line is the generated password, and the second line is the hash we could use to configure ClickHouse.

Here is an example configuration for mysql_user that uses the generated hash:

/etc/clickhouse-server/users.d/mysql_user.xml

Replace password_double_sha1_hex entry with your own generated Double SHA1 hash.

Additionally, it is recommended to use use_mysql_types_in_show_columns to show the native MySQL types instead of ClickHouse ones in SHOW [FULL] COLUMNS query results, which allows BI tools to properly introspect the database schema when using MySQL connectors.

For example:

/etc/clickhouse-server/users.d/mysql_user.xml

or assign it to a different profile instead of the default one.

If you have the mysql binary available, you can test the connection from the commandline. Using the sample username (mysql_user) and password (LZOQYnqQN4L/T6L0) from above the command line would be:

Finally, configure the Clickhouse Server to listen on the desired IP address(es). For example, in config.xml, uncomment out the following to listen on all addresses:

Подключение Looker Studio к ClickHouse

Сначала войдите на https://lookerstudio.google.com, используя свою учетную запись Google, и создайте новый источник данных:

Создание нового источника данных в интерфейсе Looker Studio

Найдите официальный коннектор MySQL, предоставленный Google (названный просто MySQL):

Поиск коннектора MySQL в списке коннекторов Looker Studio

Укажите данные подключения. Обратите внимание, что порт интерфейса MySQL по умолчанию равен 9004, и он может отличаться в зависимости от конфигурации вашего сервера.

Указание данных подключения ClickHouse MySQL в Looker Studio

Теперь у вас есть два варианта, как получить данные из ClickHouse. Во-первых, вы можете использовать функцию Table Browser:

Использование Table Browser для выбора таблиц ClickHouse в Looker Studio

В качестве альтернативы вы можете указать пользовательский запрос для получения ваших данных:

Использование пользовательского SQL-запроса для получения данных из ClickHouse в Looker Studio

Наконец, вы должны увидеть структуру таблицы, которую вы исследовали, и при необходимости настроить типы данных.

Просмотр структуры таблицы ClickHouse в Looker Studio

Теперь вы можете продолжить исследовать ваши данные или создать новый отчет!

Использование Looker Studio с ClickHouse Cloud

При использовании ClickHouse Cloud вам сначала необходимо включить интерфейс MySQL. Вы можете сделать это в диалоговом окне подключения, на вкладке "MySQL".

Включение интерфейса MySQL в настройках ClickHouse Cloud

В интерфейсе Looker Studio выберите опцию "Включить SSL". SSL-сертификат ClickHouse Cloud подписан Let's Encrypt. Вы можете скачать этот корневой сертификат здесь.

Конфигурация соединения Looker Studio с настройками SSL ClickHouse Cloud

Остальные шаги такие же, как указано выше в предыдущем разделе.