The Math of Clusters: Understanding Smart Data Clustering Through Our Log Anomaly Detection System. Part 1

Andrey Basov22 May 2026

Problem

Nobody can read all the logs of many services, so repeated messages must be grouped and new error types flagged. A static clustering of log embeddings degrades quietly. In the author's scenario a new error appears (an SSL handshake failure), a "database connection" cluster starts absorbing "disk full" messages, its boundary stops fitting, and nothing tells the team.

Example from the article: a team at MWS (part of MTS) runs this system on the logs of its systems and shows engineers named clusters, counts and growth per cluster in Grafana.

Solution in brief

Each log becomes a normalized embedding, and each cluster keeps running statistics that give it an adaptive boundary. A point inside a boundary joins the cluster; a point outside every boundary is stored as an anomaly and clustered at night. Cluster centroid speed and acceleration are scored to flag drifting clusters.

Questions this case answers
  • How to detect anomalous events in a stream of text records when new kinds of normal events appear every day and labels do not exist
  • How to maintain online, constant-time cluster statistics and an adaptive membership boundary as the data distribution shifts
  • How to find anomalous events in application logs without hand-written rules
  • How to decide whether a new log embedding belongs to an existing cluster or is an anomaly

Tools and methods

  • BGE-M3 — 768-dimensional log embeddings
  • Qdrant — vectors of logs and one point per cluster (centroid, statistics)
  • PostgreSQL — task configuration, process state, history
  • OpenSearch — log source and alert sink
  • Grafana — dashboards
  • PCA — dimensionality reduction when the vector has more than 128 dimensions
  • HDBSCAN — builds new clusters from anomalous points at night
  • Minimum spanning tree (MST) — density estimate inside a cluster
Continue reading — it's free

Google or a one-time email code. No password.