Opens in a new tab
Explainer

How variational autoencoders learn telemetry patterns

In brief

The encoder, latent distribution and reconstruction objective explain why a VAE can flag a legitimate traffic change while overlooking a familiar failure.

7 min read

Is this the right starting point?
Before you read
Basic machine-learning concepts and familiarity with means, variation and probability distributions.
What you will take away
Explain the VAE reconstruction/sampling loop and why anomaly scores need time-separated operational evaluation.
Sources
A conceptual VAE path sends a signal into a latent distribution, selects one sample and uses that sampled value to form a similar reconstruction. No measured signal or score is shown.
On this page4 sections

Request rate climbs, latency follows, and the queue starts to grow. Looking at those measurements separately tells you something; learning how they usually move together can tell you something else. A variational autoencoder, or VAE, learns an internal representation of data, then uses it to reconstruct an input or generate a new example. With telemetry, one input might be a window containing all three measurements.

The revealing part is the round trip. The model has to turn the window into a different representation and then turn that representation back into data resembling the original. How well it manages that trip can expose an unfamiliar pattern. To understand what the resulting score means for a service, first follow what the model was trained to do.

Why the encoder produces a distribution

An ordinary autoencoder sends an input through two parts: an encoder creates an internal representation, and a decoder tries to reconstruct the input from it. A common VAE adds a deliberate element of variation. Its encoder describes a probability distribution over plausible internal representations; sampling that distribution chooses the representation for one trip through the decoder. Training must therefore make a neighborhood of possible representations useful, rather than rely on one perfectly chosen code for each input.

For a constructed example, let each input contain request rate, latency, and queue depth for one time window. The model sees many such windows during training. Nobody has supplied internal labels saying “database problem” or “busy afternoon.” The encoder and decoder learn numerical variables that help account for the observed measurements. These variables are called latent because they are inferred inside the model rather than directly measured from the service.

The encoder estimates several possible latent values for the observed input, rather than declaring one value certain. That input-dependent distribution is called the approximate posterior. In the common Gaussian case, the sample can be written as z = μ + σ × ε: μ is its mean, σ its standard deviation and ε a sample from a standard normal distribution. This form lets training adjust the encoder's parameters using gradients, a technique called reparameterization. Kingma and Welling describe it in Auto-Encoding Variational Bayes.

Training asks the two halves to satisfy two aims together. The decoder should reconstruct the data well. At the same time, the encoder’s distribution should remain close to a chosen reference distribution, called the prior. The usual combined objective is an evidence lower bound, which training maximizes. The reconstruction term rewards retaining information about the input; the prior gives the space used for sampling a structure the model can work with.

Those aims pull in different directions. A code that memorized every window separately might reconstruct the training examples beautifully, but it would give the model little reason to organize nearby possibilities usefully. Balancing the terms shapes that organization. Once training is complete, reconstruction starts with the encoder’s distribution for a particular window; generation can instead start with a sample from the prior and ask the decoder to make an example.

A VAE encodes a distribution, then samples
A VAE encodes a distribution, then samples. Common Gaussian VAE reconstruction path: the encoder supplies μ and σ, sampling uses z = μ + σ × ε with ε drawn from a standard normal distribution, and the decoder models the input. Training balances reconstruction with regularization toward a prior; anomaly scores still require operational evaluation.
Common Gaussian VAE reconstruction path: the encoder supplies μ and σ, sampling uses z = μ + σ × ε with ε drawn from a standard normal distribution, and the decoder models the input. Training balances reconstruction with regularization toward a prior; anomaly scores still require operational evaluation.
Read diagram description

Common Gaussian VAE reconstruction path: the encoder supplies μ and σ, sampling uses z = μ + σ × ε with ε drawn from a standard normal distribution, and the decoder models the input. Training balances reconstruction with regularization toward a prior; anomaly scores still require operational evaluation. Diagram labels: Observed input x: Preprocessed telemetry window; Encoder: Approximate posterior parameters: μ and σ; Sample latent z: z = μ + σ × ε; ε ~ N(0, I); Decoder: Reconstruction / likelihood model for x.

What latent features represent

A latent dimension is not automatically a diagnosis waiting for a name. It can help organize variation without corresponding to a human-readable cause. The decoder also need not mirror the encoder’s architecture, and Gaussian distributions are a common choice rather than a requirement of every VAE. Before calling a cluster in that space a particular system fault, you need evidence connecting the two.

What you hand the model changes what it has to learn. If one field spans a much larger numerical range than another, errors in that field can dominate the reconstruction score. The score may then say more about reproducing that field than about the relationship you meant to study. Scaling, missing values, counter resets, and collection intervals deserve explicit treatment so a change in the measurement process does not masquerade as a change in the workload.

Conditional variants can incorporate context such as workload class; hierarchical variants add levels of latent structure. They offer flexibility, but also add choices that must be evaluated on the operational dataset. A more elaborate representation does not by itself establish a more useful detector.

Why unfamiliarity differs from customer harm

Consider a hypothetical detector trained on weekday traffic. A legitimate weekend promotion produces high reconstruction error, while a familiar low-level failure receives an ordinary score. The model has found unfamiliarity in the first case and familiarity in the second; neither result alone establishes the paging decision.

The same distinction appears after a software release. Resource use can change while the service continues meeting its user objective. A persistent defect can also become familiar enough to be reproduced well. Keep user-facing checks alongside the model so it cannot quietly redefine “healthy” as “something I have seen before.”

Training can fail in a more subtle way, too. In posterior collapse, the decoder learns to make little use of the latent variables. A falling aggregate loss can look encouraging while the representation you wanted contributes little. Inspect how the model uses that representation, not just whether the optimization curve moves in the expected direction.

Using reconstruction error in an operational response

The promotion and recurring failure give the evaluation a real purpose. Can the score draw useful attention to harmful behavior without paging someone for legitimate activity? Define the event and response first, then compare the VAE with simpler thresholds or seasonal residuals on those same outcomes. Set the score threshold around the costs of false alerts, missed events, and warning time someone can use. A percentile ranks unusualness; it does not decide whether an interruption helps.

Keep the future out of training. Fit the model and preprocessing on the training period, then use later periods for validation and testing. Once deployed, compare score changes with releases, instrumentation, and workload changes. The score tells you the new window fits differently; those surrounding records help explain why.

Overlapping windows make that separation easy to get wrong. Two windows can share most of their observations while landing on opposite sides of a random train/test split. The test then rewards recognition of near-neighbors rather than behavior genuinely held out in time. Separate periods and inspect long incidents that cross the split so the evaluation asks the question you intend.

Keep the source window and contributing features with the score. For the promotion, they may show why the model found the traffic unfamiliar and why no page is needed. For the recurring failure, they let you see what the model missed and which service indicator still has to catch it. The score becomes a starting point for an explanation instead of the end of one.

The two cases call for different responses. The promotion may deserve investigation without a page; the familiar failure still needs the service indicator to reveal its harm. Comparing the VAE with a simpler detector on both cases shows what its learned representation adds and what it misses. A low reconstruction error is useful information about the model’s familiarity with an input, rather than a substitute for deciding whether the service worked.

The anomaly-detection guide develops the operational comparison, while the GAN explainer shows a different approach to generation. The VAE’s distinctive contribution is a learned space from which it can reconstruct and sample data. Whether that space notices the failures your service needs to detect is the next question, answered by the held-out cases rather than by the elegance of the model.

Sources & context

Sources linked in this article. Read alongside the author’s analysis; a citation does not independently verify a publisher’s claims.

Report an error or outdated detail

Keep reading

Where to go next