Problem
Site reliability and platform teams collect many service metrics, but nobody reads them continuously. A rare event, such as one user sending millions of requests in a short interval, can consume resources and degrade other services before anyone notices. There are usually no labeled incidents to train a supervised detector. An anomaly is also not always bad: a sudden rise in purchase orders is rare but good, so business context decides what to do with an alert.
Example from the article: in an application used by 100 users, each request creates events that send more messages downstream. If one user sends millions of requests in a short interval, that is tagged as an anomaly.
Solution in brief
Fit PCA on normalized metric history, keeping only the components that explain most of the variance. Rebuild each new data point from those components. Points with a high reconstruction error are flagged as anomalies. Run the check as a scheduled job that alerts when the error crosses a threshold.
Questions this case answers
- How to flag unusual points in several correlated time-series metrics without labeled incidents, using a model simple enough to run as a scheduled job
- How to automatically catch rare, harmful events in application telemetry before they degrade other services?
- How to set up a simple unsupervised anomaly alert on a handful of correlated service metrics?
- How to choose an alert threshold for an anomaly score when there are no labeled incidents?
Tools and methods
- PCA — compresses correlated metrics into a few components and rebuilds them, so the reconstruction error serves as the anomaly score
- Reconstruction error threshold — turns the score into an alert rule
- Azure Log Analytics — central store for resource and application metrics; source of training data and of the data pulled on each run
- scikit-learn —
StandardScalerandPCAas shown in the author's notebook screenshots
Google or a one-time email code. No password.