---
title: Deploy ClickHouse with AI on Blossom
url: "/deploy/clickhouse/"
canonical_url: https://blossom88.com/deploy/clickhouse/
markdown_url: https://blossom88.com/deploy/clickhouse.md
summary: Load sample events and query pageviews and signups by channel.
categories:
- deployment
- databases
stack:
- ClickHouse
- SQL
---

# Deploy ClickHouse with AI on Blossom

[ClickHouse](https://github.com/ClickHouse/ClickHouse) is a column-oriented
database for SQL analytics. This recipe groups a small set of pageviews
and signups by the channel that brought them in.

## Ask Your Agent

> **Ask your AI agent:** Deploy ClickHouse on Blossom and help me count sample events by channel.
>
> Follow this guide: https://blossom88.com/deploy/clickhouse/

[Install the Blossom CLI and skill](https://docs.blossom88.com/learn/getting-started/install/) on your agent's machine and [choose a Location in your cloud account](https://docs.blossom88.com/learn/getting-started/choose-your-cloud/#connect-your-provider).

## How It Runs

| Part | Role | Where |
|---|---|---|
| ClickHouse | Store and aggregate events | Private Persistent Service |
| HTTP client | Write sample events and run SQL queries | Blossom Job |

## Deploy ClickHouse

Choose a compatible [official ClickHouse image](https://clickhouse.com/docs/get-started/setup/self-managed/docker).
Keep ClickHouse private, set a password for your database user, and mount
a [Persistent Service Volume](/docs/apps/persistent-services/).
ClickHouse is distributed under the
[Apache 2.0 license](https://github.com/ClickHouse/ClickHouse/blob/master/LICENSE).

<details class="optional-reading" markdown="1">
<summary>Notes for your agent</summary>

Use a single private Service with the Volume at `/var/lib/clickhouse`.
Use ClickHouse's HTTP interface on port `8123` from a Job in the same
Environment. Set `CLICKHOUSE_USER`, `CLICKHOUSE_DB` and a stable
secret for `CLICKHOUSE_PASSWORD`.

    blossom environment:deploy --id environment-100 --follow

</details>

## Count Events by Channel

Create a MergeTree table and add a few sample pageviews and signups.
Group by channel and count each action.

> **Ask your AI agent:** Help me load five sample events and count pageviews and signups by channel.

> Follow this guide: https://blossom88.com/deploy/clickhouse/



![Count the five sample events by channel.](/deploy/assets/images/clickhouse/events-by-channel.webp)

## Rerun the Query After an Update

Replace the database Container and query the same events on the Volume.

> **Ask your AI agent:** Check that the channel totals still match after replacing the ClickHouse Container.

> Follow this guide: https://blossom88.com/deploy/clickhouse/



![Read the same channel totals after replacement.](/deploy/assets/images/clickhouse/events-after-replacement.webp)

## What You Get

A private ClickHouse database with a persistent event table and a
working query you can adapt to your data.

## What You Get

- A private ClickHouse database
- Sample pageview and signup totals by channel
- The same results after replacing the database Container

Tested on Blossom: Five sample events yielded the same channel totals after replacing the ClickHouse Container.
