ClickHouse
- Tier: Free, Premium, Ultimate
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
- Status: Beta on GitLab Dedicated
ClickHouse is an open-source column-oriented database management system. It can efficiently filter, aggregate, and query across large data sets.
GitLab uses ClickHouse as a secondary data store to enable advanced analytics features such as GitLab Duo, SDLC trends, and CI Analytics. GitLab only stores data that supports these features in ClickHouse.
You should use ClickHouse Cloud to connect ClickHouse to GitLab.
Alternatively, you can bring your own ClickHouse. For more information, see ClickHouse recommendations for GitLab Self-Managed.
Analytics available with ClickHouse
After you configure ClickHouse, you can use the following analytics features:
| Feature | Description |
|---|---|
| Runner fleet dashboard | Displays runner usage metrics and job wait times. Provides export of CSV files containing job counts and executed runner minutes by runner type and job status for each project. |
| Contribution analytics | Provides analytics of group member contributions (push events, issues, merge requests) over time. ClickHouse reduces the likelihood of timeout issues for large instances. |
| GitLab Duo and SDLC trends | Measures the impact of GitLab Duo on software development performance. Tracks development metrics (deployment frequency, lead time, change failure rate, time to restore) alongside AI-specific indicators (GitLab Duo seat adoption, Code Suggestions acceptance rates, and GitLab Duo Chat usage). |
| GraphQL API for AI Metrics | Provides programmatic access to GitLab Duo and SDLC trend data through the AiMetrics, AiUserMetrics, and AiUsageData endpoints. Provides export of pre-aggregated metrics and raw event data for integration with BI tools and custom analytics. |
Supported ClickHouse versions
The supported ClickHouse version differs depending on your GitLab version:
- GitLab 17.7 and later supports ClickHouse 23.x. To use either ClickHouse 24.x or 25.x, use the workaround.
- GitLab 18.1 and later supports ClickHouse 23.x, 24.x, and 25.x.
- GitLab 18.8 and later supports ClickHouse 23.x, 24.x, 25.x, and the Replicated database engine.
- Older clusters will require an additional permission (
dictGet), see the snippet.
- Older clusters will require an additional permission (
- GitLab 19.0 and later supports ClickHouse 25.x and 26.x up to and including 26.6. Support for ClickHouse 23.x and 24.x has been removed.
- ClickHouse 26.7 and later is not supported. For a temporary workaround, see ClickHouse 26.7 and later.
ClickHouse Cloud is always compatible with the latest stable GitLab release.
Some ClickHouse versions introduce backward-incompatible changes that affect the GitLab integration:
- ClickHouse 25.12 introduced a backward-incompatible change to
ALTER MODIFY COLUMN. This breaks the migration process for the GitLab ClickHouse integration in versions prior to 18.8. It requires upgrading GitLab to version 18.8+. - ClickHouse 26.7 added a validation for
AggregatingMergeTreetables that GitLab does not yet satisfy, so migrations fail with aCode: 36(BAD_ARGUMENTS) error. For a temporary workaround, see ClickHouse 26.7 and later.
Set up ClickHouse
Choose your deployment type based on your operational requirements:
- ClickHouse Cloud (Recommended): Fully managed service with automatic upgrades, backups, and scaling.
- ClickHouse for GitLab Self-Managed (BYOC): Complete control over your infrastructure and configuration.
After setting up your ClickHouse instance:
- Create the GitLab database and user.
- Configure the GitLab connection.
- Verify the connection.
- Run ClickHouse migrations.
- Enable ClickHouse for Analytics.
Set up ClickHouse Cloud
Prerequisites:
- Have a ClickHouse Cloud account.
- Enable network connectivity from your GitLab instance to ClickHouse Cloud.
- Be an administrator of your GitLab instance.
To set up ClickHouse Cloud:
- Sign in to ClickHouse Cloud.
- Select New Service.
- Choose your service tier:
- Development: For testing and development environments.
- Production: For production workloads with high availability.
- Select your cloud provider and region. Choose a region close to your GitLab instance for optimal performance.
- Configure your service name and settings.
- Select Create Service.
- Once provisioned, note your connection details from the service dashboard:
- Host
- Port (
8443for HTTPS connections used by GitLab, or9440for native TCP with TLS used byclickhouse-client) - Username
- Password
ClickHouse Cloud automatically handles version upgrades and security patches. Enterprise Edition (EE) customers can schedule upgrades to control when they occur, and avoid unexpected service interruptions during business hours. For more information, see upgrade ClickHouse.
After you create your ClickHouse Cloud service, you then create the GitLab database and user.
Set up ClickHouse for GitLab Self-Managed (BYOC)
Prerequisites:
- Have a ClickHouse instance installed and running. If ClickHouse is not installed, see:
- Have a supported ClickHouse version.
- Enable network connectivity from your GitLab instance to ClickHouse.
- Be an Administrator for both ClickHouse and your GitLab instance.
For ClickHouse for GitLab Self-Managed, you are responsible for planning and executing version upgrades, security patches, and backups. For more information, see Upgrade ClickHouse.
Configure High Availability
For a multi-node, high-availability (HA) setup, GitLab supports the Replicated table engine in ClickHouse.
Prerequisites:
- Have a ClickHouse cluster with multiple nodes. A minimum of three nodes is recommended.
- Define a cluster in the
remote_serversconfiguration section. - Configure the following macros in your ClickHouse configuration:
clustershardreplica
When configuring the database for HA, you must run the statements with the ON CLUSTER clause.
For more information, see ClickHouse Replicated database engine documentation.
Configure Load balancer
The GitLab application communicates with the ClickHouse cluster through the HTTP/HTTPS interface. For HA deployments, use an HTTP proxy or load balancer to distribute requests across ClickHouse cluster nodes.
Recommended load balancer options:
- chproxy - ClickHouse-specific HTTP proxy with built-in caching and routing.
- HAProxy - General-purpose TCP/HTTP load balancer.
- NGINX - Web server with load balancing capabilities.
- Cloud provider load balancers (AWS Application Load Balancer, GCP Load Balancer, Azure Load Balancer).
Basic chproxy configuration example:
server:
http:
listen_addr: ":8080"
clusters:
- name: "clickhouse_cluster"
nodes: [
"http://ch-node1:8123",
"http://ch-node2:8123",
"http://ch-node3:8123"
]
users:
- name: "gitlab"
password: "your_secure_password"
to_cluster: "clickhouse_cluster"
to_user: "gitlab"When using a load balancer, configure GitLab to connect to the load balancer URL instead of individual ClickHouse nodes.
For more information, see chproxy documentation.
After you configure your ClickHouse for GitLab Self-Managed instance, create the GitLab database and user.
Verify ClickHouse installation
Before configuring the database, verify ClickHouse is installed and accessible:
Check ClickHouse is running:
clickhouse-client --query "SELECT version()"If ClickHouse is running, you see the version number (for example,
24.3.1.12).Verify you can connect with credentials:
clickhouse-client --host your-clickhouse-host --port 9440 --secure --user default --password 'your-password'If you have not configured TLS yet, use port
9000without the--secureflag for initial testing.
Create database and user
To create the necessary user and database objects:
- Generate a secure password and save it.
- Sign in to:
- For ClickHouse Cloud, the ClickHouse SQL console.
- For ClickHouse for GitLab Self-Managed, the
clickhouse-client.
- Run the following commands, replacing
PASSWORD_HEREwith the generated password.
CREATE DATABASE gitlab_clickhouse_main_production;
CREATE USER gitlab IDENTIFIED WITH sha256_password BY 'PASSWORD_HERE';
CREATE ROLE gitlab_app;
GRANT SELECT, INSERT, ALTER, CREATE, UPDATE, DROP, TRUNCATE, OPTIMIZE, dictGet ON gitlab_clickhouse_main_production.* TO gitlab_app;
GRANT SELECT ON information_schema.* TO gitlab_app;
GRANT gitlab_app TO gitlab;Replace CLUSTER_NAME_HERE with your cluster’s name:
CREATE DATABASE gitlab_clickhouse_main_production ON CLUSTER CLUSTER_NAME_HERE ENGINE = Replicated('/clickhouse/databases/{cluster}/gitlab_clickhouse_main_production', '{shard}', '{replica}');
CREATE USER gitlab IDENTIFIED WITH sha256_password BY 'PASSWORD_HERE' ON CLUSTER CLUSTER_NAME_HERE;
CREATE ROLE gitlab_app ON CLUSTER CLUSTER_NAME_HERE;
GRANT SELECT, INSERT, ALTER, CREATE, UPDATE, DROP, TRUNCATE, OPTIMIZE, dictGet ON gitlab_clickhouse_main_production.* TO gitlab_app ON CLUSTER CLUSTER_NAME_HERE;
GRANT SELECT ON information_schema.* TO gitlab_app ON CLUSTER CLUSTER_NAME_HERE;
GRANT gitlab_app TO gitlab ON CLUSTER CLUSTER_NAME_HERE;Configure the GitLab connection
To provide GitLab with ClickHouse credentials:
Edit
/etc/gitlab/gitlab.rb:gitlab_rails['clickhouse_databases']['main']['database'] = 'gitlab_clickhouse_main_production' gitlab_rails['clickhouse_databases']['main']['url'] = 'https://your-clickhouse-host:port' gitlab_rails['clickhouse_databases']['main']['username'] = 'gitlab' gitlab_rails['clickhouse_databases']['main'][