docker.recipes

ClickHouse Analytics Stack

intermediate

ClickHouse OLAP database with Grafana, Vector for log ingestion, and Tabix UI

Overview

ClickHouse is a lightning-fast column-oriented database designed specifically for online analytical processing (OLAP), developed by Yandex to handle billions of rows per second with real-time query performance. Its columnar storage architecture and advanced compression algorithms make it exceptionally efficient for analytical workloads, time-series data, and log processing at massive scale. Unlike traditional row-based databases, ClickHouse excels at aggregating large datasets and executing complex analytical queries with sub-second response times. This analytics stack combines ClickHouse's raw analytical power with Vector's high-performance log ingestion, Grafana's rich visualization capabilities, and Tabix's intuitive SQL interface to create a complete analytics pipeline. Vector acts as the data collection layer, efficiently ingesting logs and metrics from various sources and streaming them into ClickHouse, while Grafana transforms the stored data into actionable dashboards and alerts. The integration enables real-time analytics workflows where data flows from collection through storage to visualization without leaving the stack. This combination is particularly valuable for organizations processing large volumes of time-series data, application logs, or business metrics who need both the performance of ClickHouse and the accessibility of visual dashboards. The stack provides data teams with SQL-native analytics capabilities while offering stakeholders familiar Grafana interfaces for monitoring and business intelligence.

Key Features

  • Column-oriented storage with advanced compression reducing storage costs by 10-100x compared to traditional databases
  • Vector's rust-based log processing with support for 50+ data sources and transformation capabilities
  • Tabix web-based SQL client with query builder, result visualization, and ClickHouse-specific optimizations
  • Grafana ClickHouse datasource plugin enabling native integration with dashboard templating and alerting
  • Real-time data ingestion pipeline supporting structured logs, metrics, and time-series data
  • Materialized views in ClickHouse for pre-aggregated analytics and faster dashboard queries
  • Vector's adaptive request concurrency automatically optimizing ingestion throughput to ClickHouse
  • MergeTree engine family providing automatic data partitioning and primary key optimization

Common Use Cases

  • 1Real-time application log analytics for debugging and performance monitoring across microservices
  • 2Business intelligence dashboards analyzing user behavior, conversion funnels, and revenue metrics
  • 3Infrastructure monitoring storing and visualizing metrics from servers, containers, and cloud services
  • 4E-commerce analytics tracking product views, cart abandonment, and customer journey analysis
  • 5IoT data processing for sensor readings, device telemetry, and predictive maintenance analytics
  • 6Financial data analysis including trading analytics, risk assessment, and regulatory reporting
  • 7Gaming analytics processing player events, retention analysis, and monetization tracking

Prerequisites

  • Minimum 8GB RAM recommended for ClickHouse with analytical workloads (2GB absolute minimum)
  • Docker and Docker Compose with available ports 3000, 8123, 8124, and 9000
  • Vector configuration file (vector.toml) defining data sources and ClickHouse sink settings
  • Basic SQL knowledge for creating ClickHouse tables and understanding columnar database concepts
  • Understanding of time-series data patterns and analytical query optimization techniques

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 clickhouse:
3 image: clickhouse/clickhouse-server:latest
4 container_name: clickhouse
5 restart: unless-stopped
6 ports:
7 - "${CH_HTTP_PORT:-8123}:8123"
8 - "${CH_NATIVE_PORT:-9000}:9000"
9 environment:
10 - CLICKHOUSE_USER=${CH_USER:-default}
11 - CLICKHOUSE_PASSWORD=${CH_PASSWORD}
12 - CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1
13 volumes:
14 - clickhouse_data:/var/lib/clickhouse
15 - clickhouse_logs:/var/log/clickhouse-server
16 ulimits:
17 nofile:
18 soft: 262144
19 hard: 262144
20
21 tabix:
22 image: spoonest/clickhouse-tabix-web-client:latest
23 container_name: tabix
24 restart: unless-stopped
25 ports:
26 - "${TABIX_PORT:-8124}:80"
27 depends_on:
28 - clickhouse
29
30 vector:
31 image: timberio/vector:latest-alpine
32 container_name: vector
33 restart: unless-stopped
34 volumes:
35 - ./vector/vector.toml:/etc/vector/vector.toml:ro
36 - /var/log:/var/log:ro
37 depends_on:
38 - clickhouse
39
40 grafana:
41 image: grafana/grafana:latest
42 container_name: clickhouse-grafana
43 restart: unless-stopped
44 ports:
45 - "${GRAFANA_PORT:-3000}:3000"
46 environment:
47 - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}
48 - GF_INSTALL_PLUGINS=grafana-clickhouse-datasource
49 volumes:
50 - grafana_data:/var/lib/grafana
51 depends_on:
52 - clickhouse
53
54volumes:
55 clickhouse_data:
56 clickhouse_logs:
57 grafana_data:

.env Template

.env
1# ClickHouse Analytics Stack
2CH_HTTP_PORT=8123
3CH_NATIVE_PORT=9000
4TABIX_PORT=8124
5GRAFANA_PORT=3000
6
7# ClickHouse
8CH_USER=default
9CH_PASSWORD=clickhouse_password
10
11# Grafana
12GRAFANA_PASSWORD=admin

Usage Notes

  1. 1ClickHouse HTTP API at http://localhost:8123
  2. 2Tabix SQL client at http://localhost:8124
  3. 3Grafana at http://localhost:3000 (admin/admin)
  4. 4Create vector.toml config for log ingestion
  5. 5Add ClickHouse datasource in Grafana
  6. 6ClickHouse excels at analytics and log analysis

Individual Services(4 services)

Copy individual services to mix and match with your existing compose files.

clickhouse
clickhouse:
  image: clickhouse/clickhouse-server:latest
  container_name: clickhouse
  restart: unless-stopped
  ports:
    - ${CH_HTTP_PORT:-8123}:8123
    - ${CH_NATIVE_PORT:-9000}:9000
  environment:
    - CLICKHOUSE_USER=${CH_USER:-default}
    - CLICKHOUSE_PASSWORD=${CH_PASSWORD}
    - CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1
  volumes:
    - clickhouse_data:/var/lib/clickhouse
    - clickhouse_logs:/var/log/clickhouse-server
  ulimits:
    nofile:
      soft: 262144
      hard: 262144
tabix
tabix:
  image: spoonest/clickhouse-tabix-web-client:latest
  container_name: tabix
  restart: unless-stopped
  ports:
    - ${TABIX_PORT:-8124}:80
  depends_on:
    - clickhouse
vector
vector:
  image: timberio/vector:latest-alpine
  container_name: vector
  restart: unless-stopped
  volumes:
    - ./vector/vector.toml:/etc/vector/vector.toml:ro
    - /var/log:/var/log:ro
  depends_on:
    - clickhouse
grafana
grafana:
  image: grafana/grafana:latest
  container_name: clickhouse-grafana
  restart: unless-stopped
  ports:
    - ${GRAFANA_PORT:-3000}:3000
  environment:
    - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}
    - GF_INSTALL_PLUGINS=grafana-clickhouse-datasource
  volumes:
    - grafana_data:/var/lib/grafana
  depends_on:
    - clickhouse

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 clickhouse:
5 image: clickhouse/clickhouse-server:latest
6 container_name: clickhouse
7 restart: unless-stopped
8 ports:
9 - "${CH_HTTP_PORT:-8123}:8123"
10 - "${CH_NATIVE_PORT:-9000}:9000"
11 environment:
12 - CLICKHOUSE_USER=${CH_USER:-default}
13 - CLICKHOUSE_PASSWORD=${CH_PASSWORD}
14 - CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1
15 volumes:
16 - clickhouse_data:/var/lib/clickhouse
17 - clickhouse_logs:/var/log/clickhouse-server
18 ulimits:
19 nofile:
20 soft: 262144
21 hard: 262144
22
23 tabix:
24 image: spoonest/clickhouse-tabix-web-client:latest
25 container_name: tabix
26 restart: unless-stopped
27 ports:
28 - "${TABIX_PORT:-8124}:80"
29 depends_on:
30 - clickhouse
31
32 vector:
33 image: timberio/vector:latest-alpine
34 container_name: vector
35 restart: unless-stopped
36 volumes:
37 - ./vector/vector.toml:/etc/vector/vector.toml:ro
38 - /var/log:/var/log:ro
39 depends_on:
40 - clickhouse
41
42 grafana:
43 image: grafana/grafana:latest
44 container_name: clickhouse-grafana
45 restart: unless-stopped
46 ports:
47 - "${GRAFANA_PORT:-3000}:3000"
48 environment:
49 - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}
50 - GF_INSTALL_PLUGINS=grafana-clickhouse-datasource
51 volumes:
52 - grafana_data:/var/lib/grafana
53 depends_on:
54 - clickhouse
55
56volumes:
57 clickhouse_data:
58 clickhouse_logs:
59 grafana_data:
60EOF
61
62# 2. Create the .env file
63cat > .env << 'EOF'
64# ClickHouse Analytics Stack
65CH_HTTP_PORT=8123
66CH_NATIVE_PORT=9000
67TABIX_PORT=8124
68GRAFANA_PORT=3000
69
70# ClickHouse
71CH_USER=default
72CH_PASSWORD=clickhouse_password
73
74# Grafana
75GRAFANA_PASSWORD=admin
76EOF
77
78# 3. Start the services
79docker compose up -d
80
81# 4. View logs
82docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/clickhouse-analytics-stack/run | bash

Troubleshooting

  • ClickHouse 'Memory limit exceeded' errors: Increase max_memory_usage setting or add more RAM to handle large analytical queries
  • Vector failing to connect to ClickHouse: Verify ClickHouse is accepting connections on port 9000 and vector.toml has correct endpoint configuration
  • Grafana ClickHouse datasource connection refused: Ensure ClickHouse HTTP interface is enabled on port 8123 and user has proper permissions
  • Tabix showing 'CORS policy' errors: Configure ClickHouse http_server_default_response header to allow cross-origin requests
  • Slow query performance in ClickHouse: Check table ENGINE type, ensure proper partitioning key, and verify queries use primary key columns
  • Vector consuming high CPU during log ingestion: Reduce batch size in vector.toml and implement rate limiting for high-volume log sources

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Components

clickhousegrafanavectortabix

Tags

#clickhouse#analytics#olap#grafana#logs#time-series

Category

Database Stacks
Ad Space