Emre Şahin

Diário de engenharia

Six Detectors, One Vote

Ensemble anomaly detection by majority vote, root-cause ranking with Granger causality, and why false positives are a cost you design for.

Emre Şahin ·

When I started on the observation plane of FaultMesh, the tempting path was obvious: pick the best anomaly detection model I could find, tune it hard, ship it.

I did not do that. The observation plane runs six fairly ordinary detectors and lets them vote. This post explains why, and what the trade-offs look like in practice.

The job is narrower than "find anomalies"

In a chaos platform, anomaly detection has a specific job. A fault was injected at a known time. The question is: did the system's behaviour change in a way that matters, and when did we first see it? That timestamp becomes DetectedAt, and MTTD is computed from it.

That framing changes what "good" means. I don't need a detector that finds every subtle shift in a metric. I need one that:

  • fires reliably when something real is happening,
  • does not fire when nothing is,
  • can explain itself to an operator who did not build it.

The third point is underrated. An ops team will not trust an alert they cannot reason about, and an untrusted alert is worse than none, because it trains people to ignore the channel.

Six detectors, each with a blind spot

Every detector is simple on its own, and each fails in a different way:

  • Z-score over a sliding window. Catches sudden spikes. Fooled by anything seasonal.
  • CUSUM. Catches small, sustained shifts that a Z-score misses. Slow to react to a single spike.
  • Holt-Winters. Models level, trend and seasonality, then flags deviation from the forecast. Needs history; unhelpful on a fresh service.
  • STL decomposition residuals. Strips trend and seasonality and looks at what is left. Good for daily and weekly patterns. Sensitive to how you pick the period.
  • Isolation Forest (ML.NET), trained on a baseline window. Catches multivariate oddities. Opaque, and only as good as its baseline.
  • Granger causality. Not a point detector in the usual sense; it asks whether one series helps predict another. It earns its place in root-cause ranking more than in detection.

The defaults are deliberately boring: a Z-score threshold of 3, a CUSUM threshold of 5 sigma, 3 sigma for Holt-Winters and STL residuals, a contamination rate of 1% for Isolation Forest, a 30-second polling interval. None of these are tuned to make a benchmark look good.

The vote

The ensemble runs every detector in parallel on the same series and counts how many flagged it:

var results   = await Task.WhenAll(_detectors.Select(d => d.DetectAsync(series, ct)));
var triggered = results.Where(r => r.IsAnomaly).ToArray();

var isAnomaly  = triggered.Length >= settings.EnsembleMinAgreement; // default 2
var confidence = (double)triggered.Length / results.Length;

An anomaly needs at least two detectors to agree. Confidence is simply the share that agreed. Severity is mapped from confidence: 0.8 and above is critical, 0.5 high, 0.2 medium, below that low. The result carries the names of the detectors that fired.

That last detail is the explainability story. When an operator sees "High, confidence 0.67, flagged by CUSUM, Holt-Winters, STL, Z-score", they can reason about it. A sustained shift that also breaks the seasonal forecast is a very different signal from a lone Isolation Forest hit.

Why not one clever model?

I considered a single, stronger model, most likely a well-tuned Isolation Forest or a learned forecaster with a threshold. Three reasons pushed me away from it.

Independent failure modes. The point of an ensemble is not that each member is good. It is that they are wrong about different things. Z-score is fooled by seasonality; STL is not. Holt-Winters is useless without history; Z-score does not care. Requiring agreement filters out the failure mode specific to any one method. A single model, however clever, has one set of blind spots, and you usually find them during an incident.

Debuggability. Each detector can be tested in isolation with a synthetic series. When the ensemble misbehaves, I can see which member voted and why. With a single learned model, "why did it fire?" often has no satisfying answer.

Graceful degradation. A fresh service has no history. Holt-Winters and Isolation Forest have little to say. The ensemble still works with the detectors that do have something to say; it just reports lower confidence. A single model in that situation is either silent or guessing.

The cost is real, though. Six detectors use more CPU than one. The ensemble's confidence is not a calibrated probability; it is a vote share, and I am careful not to present it as more than that. And "two of six" is a crude rule that treats every detector as equally trustworthy. Weighted voting is an obvious next step, but I would rather earn it with data than guess the weights now.

False positives are a cost, not a statistic

It is easy to talk about precision and recall as abstract numbers. In operations, a false positive has a concrete price.

In FaultMesh an AnomalyDetected event can trigger remediation. A false positive is not just a noisy notification; it can restart pods, shift traffic or roll back a deployment that was fine. Every false positive also inflates the confidence of your detection stats, because MTTD looks great when the detector fires at everything.

So I treat the agreement threshold as a cost decision. Two out of six is a starting point that favours avoiding false positives over catching everything. Remediation adds a second filter: policy decides what may run automatically, and destructive actions can require approval. Detection and action are decoupled on purpose; a detector being confident is not the same as being allowed to act.

From "something is wrong" to "where"

Detecting an anomaly on five services at once is not very useful. In a real dependency graph, one fault upstream shows up everywhere downstream. The operator's real question is: which one started it?

The RootCauseAnalyzer uses pairwise Granger causality for that. For each pair of service series, it asks whether the history of A improves the prediction of B beyond B's own history, using a lag of 5 steps and a p-value threshold of 0.05. Each time a service significantly "Granger-causes" another, it gains score, weighted by how strong the evidence is. Services are then ranked by that score, which grows with the number of downstream services they appear to drive.

payments-db  → Granger-causes 3 downstream: payments-api, checkout, orders
payments-api → Granger-causes 1 downstream: checkout
checkout     → (none)

The output is a ranked list with a plain-language reason, not a single verdict. That is intentional.

Granger causality is not causality. It is predictive precedence. Two services driven by a shared dependency you are not measuring will look causally linked. A service with a short series is skipped entirely, because the test needs enough data points relative to the lag. I present the ranking as "probable root causes" because that is what it is. Calling it more would be overselling, and in ops, overselling costs trust that is hard to win back.

Correlating across signals

Metrics are not the only evidence. A cross-signal correlator links a metric spike to traces through exemplar trace ids, traces to logs by trace id, and logs to Kubernetes events by pod name, all within a 30-second window. When it works, an operator gets a short chain: this metric moved, these traces were slow, these log lines errored, this pod was OOM-killed. That is often more useful than any score.

What I'd say to a team building this

Start with simple detectors you can explain. Require agreement. Make the output say which detectors fired. Treat the threshold as a business decision about the cost of being wrong, not a tuning knob. Keep detection separate from the authority to act.

None of this is novel. That is the point. In operations, a boring system that people trust beats a clever one they mute.

FaultMesh is a personal product under active development. More at faultmesh.com.