Getting Started
This guide will help you get ClickLens up and running with your ClickHouse database.
1. Prerequisites
Before installing ClickLens, ensure you have:
- A running ClickHouse server (version 21.8 or later recommended)
- ClickHouse HTTP interface enabled (ports 8123 for HTTP, 8443 for HTTPS)
- A ClickHouse user account with appropriate permissions
ClickLens uses the ClickHouse HTTP interface (ports 8123/8443). The native TCP protocol (ports 9000/9440) is NOT supported.
2. Installation
2.1. Option 1: Docker (Recommended)
The fastest way to run ClickLens is with Docker:
docker run -d \
--name clicklens \
-p 3000:3000 \
-e CLICKHOUSE_HOST=your-clickhouse-host \
-e CLICKHOUSE_PORT=8123 \
-e LENS_USER=lensuser \
-e LENS_PASSWORD=your-password \
-e SESSION_SECRET=your-32-character-secret-key-here \
ghcr.io/ntk148v/clicklens:latestThen open http://localhost:3000 (opens in a new tab) in your browser.
2.2. Option 2: Docker Compose
Create a docker-compose.yml file:
services:
app:
image: ghcr.io/ntk148v/clicklens:latest
ports:
- "3000:3000"
environment:
- CLICKHOUSE_HOST=your-clickhouse-host
- CLICKHOUSE_PORT=8123
- LENS_USER=lensuser
- LENS_PASSWORD=your-password
- SESSION_SECRET=your-32-character-secret-key-here
- NODE_ENV=production
- DISABLE_SECURE_COOKIES=true
restart: unless-stoppedThen run:
docker-compose up -d2.3. Option 3: Local Development
For local development with Bun:
# Clone the repository
git clone https://github.com/ntk148v/clicklens.git
cd clicklens
# Install dependencies
bun install
# Copy environment file
cp env.sample .env.local
# Edit .env.local with your ClickHouse connection details
# Then start the development server
bun devThe app will be available at http://localhost:3000 (opens in a new tab).
3. Understanding the Service User
ClickLens uses two types of ClickHouse connections:
3.1. Lens Service User (Environment Credentials)
Configured via LENS_USER and LENS_PASSWORD environment variables. This service account is used for:
- Schema introspection and metadata queries
- System table access for monitoring features
- Background operations that don't require user context
Recommended minimal grants:
CREATE USER lensuser IDENTIFIED BY 'your-password';
GRANT SELECT ON system.* TO lensuser;
GRANT SHOW DATABASES ON *.* TO lensuser;
GRANT SHOW TABLES ON *.* TO lensuser;
GRANT SHOW COLUMNS ON *.* TO lensuser;3.2. User Client (Session Credentials)
When you log in to ClickLens, your ClickHouse username and password are used directly for:
- Executing your SQL queries
- Determining your UI permissions
- All data access operations
Your permissions in ClickLens are determined by your ClickHouse user's grants and roles. ClickLens does not add or remove permissions—it simply reflects what your ClickHouse account can do.
4. ClickHouse System Tables
ClickLens relies on ClickHouse's built-in system tables to provide its features. Understanding which tables are used helps with permission planning and troubleshooting.
4.1. System Tables by Feature
| Feature | System Tables Used | Purpose |
|---|---|---|
| Monitoring Overview | system.metrics, system.asynchronous_metrics, system.events, system.query_log | Server metrics, uptime, query throughput |
| Cluster Health | system.clusters, system.replicas, system.replication_queue | Cluster topology, node status, replication state |
| Disk Usage | system.disks, system.parts | Storage capacity, compression ratios |
| Query Analytics | system.processes, system.query_log, system.query_cache | Running queries, history, cache stats |
| Table Explorer | system.tables, system.columns, system.parts, system.merges, system.mutations | Schema browsing, part information |
| Keeper/ZooKeeper | system.metrics (ZooKeeper*), system.events (ZooKeeper*) | Coordination service health |
| Logging | system.text_log, system.session_log, system.crash_log | Server and session logs |
| Settings | system.settings, system.server_settings | Configuration values |
| Time-Series Charts | system.metric_log, system.query_log | Historical metrics for graphs |
The system.metric_log table must be enabled in ClickHouse's config for
time-series graphs to work. See the ClickHouse metric_log
documentation (opens in a new tab).
4.2. Optional System Tables
Some ClickLens features depend on tables that may not exist by default:
| Table | When Created | Feature Impact |
|---|---|---|
system.text_log | Must be enabled in config | Server logs viewer |
system.session_log | Must be enabled in config | Session logs viewer |
system.crash_log | Created when crashes occur | Crash logs viewer |
system.metric_log | Must be enabled in config | Time-series monitoring charts |
system.query_log | Enabled by default | Query history and analytics |
To enable optional logging tables, add to your ClickHouse config.xml:
<clickhouse>
<!-- Enable text_log for server logs -->
<text_log>
<database>system</database>
<table>text_log</table>
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
</text_log>
<!-- Enable session_log for login tracking -->
<session_log>
<database>system</database>
<table>session_log</table>
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
</session_log>
<!-- Enable metric_log for time-series charts -->
<metric_log>
<database>system</database>
<table>metric_log</table>
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
<collect_interval_milliseconds>1000</collect_interval_milliseconds>
</metric_log>
</clickhouse>5. First Login
- Navigate to http://localhost:3000 (opens in a new tab)
- Enter your ClickHouse credentials:
- Username: Your ClickHouse user
- Password: Your ClickHouse password
- Click Login
Upon successful login, you'll be taken to the Dashboard.
6. The Dashboard
The Dashboard is your starting point in ClickLens. It displays feature cards based on your permissions:
| Feature | Description | Required Permission |
|---|---|---|
| SQL Console | Execute queries with syntax highlighting and auto-completion | canExecuteQueries |
| Table Explorer | Browse databases, tables, and parts | canBrowseTables |
| Query Monitoring | Monitor running queries and view history | canViewProcesses |
| Cluster Health | CPU, memory, merges, and Keeper status | canViewCluster |
| Access Control | Manage users and roles | canManageUsers |
| Logging | View system and query logs | canViewCluster |
Feature cards are dynamically shown or hidden based on your ClickHouse user's permissions. If you're missing expected features, check your ClickHouse grants.
7. Next Steps
- Explore the Features guide to learn about each module
- Read about Deployment for production configuration
- Check the Architecture documentation for technical details