---
title: "Using Event Patterns in ClickStack to accelerate observability analysis"
description: "ClickStack clusters logs and traces into event patterns at query time using the Drain3 template-mining algorithm, which runs in the browser via Pyodide (Python compiled to WebAssembly)."
url: "https://swe.quest/articles/using-event-patterns-in-clickstack-to-accelerate-observability-analysis-7a0fbc615de3ddd6"
canonical: "https://clickhouse.com/blog/event-patterns-clickstack"
source: "ClickHouse"
published: "2025-11-26"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 9
tags: ["observability","analytics","algorithms"]
---

# Using Event Patterns in ClickStack to accelerate observability analysis

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2025-11-26, 9 min read, Deep dive. Original: [https://clickhouse.com/blog/event-patterns-clickstack](https://clickhouse.com/blog/event-patterns-clickstack)

## Summary

ClickStack clusters logs and traces into event patterns at query time using the Drain3 template-mining algorithm, which runs in the browser via Pyodide (Python compiled to WebAssembly). Clustering at ingest was rejected because the overhead is too high at gigabytes-per-second ingestion rates. Instead, each search result set is sampled down to about 10,000 evenly distributed events with a cityHash64-modulo sampling query that avoids ORDER BY rand(), returning clusters within seconds. The recommended workflow is to filter broadly by service or severity, treat rare patterns as leads, then pivot to raw search or traces. Future work could run Drain3 as a ClickHouse UDF and compile the learned templates into ingest-time extraction rules for better compression.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Observability](https://swe.quest/tags/observability.md) (Reliability & operations)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Algorithms](https://swe.quest/tags/algorithms.md) (Architecture & design)

## Prerequisites

- log management basics ([easy posts on Engineering management](https://swe.quest/tags/engineering-management.md?difficulty=easy))
- SQL ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))

## Keywords

ClickStack, ClickHouse, Drain3, Pyodide, WebAssembly, OpenTelemetry

## Related posts

- [Improve logs compression with log clustering](https://swe.quest/articles/improve-logs-compression-with-log-clustering-6656d2f1ad6f9ec5.md): ClickHouse · 2025-10-30 · Medium · 16 min read · Observability, Analytics & OLAP, Data pipelines, Algorithms
  Drain3 log template mining, run inside ClickHouse as a Python executable UDF, can turn unstructured application logs into structured columnar data.
- [How Canva achieved 10x faster search and 70% lower costs with ClickHouse](https://swe.quest/articles/how-canva-achieved-10x-faster-search-and-70-lower-costs-with-clickhouse-40e415ef239059a0.md): ClickHouse · 2025-12-01 · Medium · 7 min read · Observability, Analytics & OLAP, Cost optimization, Performance engineering, Databases
  Canva moved tracing and logging (about 3 million spans and 3 million logs per second) onto a self-managed ClickHouse cluster of 5 shards × 3 replicas on Kubernetes.
- [How we made ClickStack 5x faster for ClickHouse observability](https://swe.quest/articles/how-we-made-clickstack-5x-faster-for-clickhouse-observability-ed934241e77977aa.md): ClickHouse · 2026-07-02 · Hard · 22 min read · Observability, Analytics & OLAP, Performance engineering, Query engines, Storage engines
  ClickStack's OpenTelemetry logs schema, inherited from the ClickHouse exporter for the OTel Collector, was reworked through a benchmark-driven process.
- [What's new in ClickStack - May 2026](https://swe.quest/articles/what-s-new-in-clickstack-may-2026-9dca7663001ee0ca.md): ClickHouse · 2026-06-23 · Easy · 12 min read · Observability, Analytics & OLAP, AI agents
  ClickStack's May 2026 update focuses on making dashboards useful during investigations.
- [ClickStack: A (half) year in review](https://swe.quest/articles/clickstack-a-half-year-in-review-cf0d67e92c68a1b1.md): ClickHouse · 2026-01-06 · Easy · 12 min read · Observability, Analytics & OLAP, Performance engineering
  ClickStack, the ClickHouse-based observability stack built on HyperDX and OpenTelemetry, shipped a run of features between its May launch and December.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
