Skip to main content

Analysis of Netdata's ML Anomaly Detection System

Abstract

This document is an analysis of Netdata's machine learning approach to anomaly detection. The system employs an ensemble of k-means clustering models with a consensus-based decision mechanism, achieving a calculated false positive rate of 10^-36 per metric. This analysis examines the mathematical foundations, design trade-offs, and operational characteristics of the implementation.

System Overview

Netdata's anomaly detection system operates on the following principles:

  • Algorithm: Unsupervised k-means clustering (k=2) implemented via the dlib library
  • Architecture: 18 models per metric, each trained on 6-hour windows staggered at 3-hour intervals
  • Decision mechanism: Unanimous consensus required across all models
  • Computational model: Edge-based processing on each monitored host
  • Storage mechanism: Single bit per metric per second embedded in existing time-series format

Mathematical Analysis

Clustering Algorithm

The system employs k-means clustering with k=2, effectively partitioning each metric's behavioral space into "normal" and "potentially anomalous" clusters. The choice of k=2 represents a fundamental design decision prioritizing simplicity and interpretability over nuanced classification.

Feature Engineering: Each data point is transformed into a 6-dimensional feature vector:

  • Dimension 1: Differenced value (current - previous)
  • Dimension 2: Smoothed value (3-point simple moving average using t-2, t-1, and t for 1-second metrics; raw value for others)
  • Dimensions 3-6: Lagged values (t-1 through t-4)

This feature space captures both instantaneous changes and temporal patterns while remaining computationally tractable.

Anomaly Scoring

The anomaly score calculation employs min-max normalization:

distance = ||x - μ||₂  where μ ∈ {c₁, c₂}, the nearest of the two cluster centers
score = 100 × (distance - min_distance) / (max_distance - min_distance)

Where min_distance and max_distance are determined during training. A score ≥ 99 indicates the point lies at or beyond the extremes observed during training.

Consensus Mechanism

The false positive rate calculation assumes independence among models:

P(false positive) = P(all 18 models flag anomaly | no true anomaly)
= ∏ᵢ₌₁¹⁸ P(model i flags anomaly | no true anomaly)
= (0.01)¹⁸
= 10⁻³⁶

The independence assumption is justified by:

  1. Each model evaluates previously unseen data points
  2. Models maintain distinct normalization boundaries from their unique training windows
  3. The temporal offset ensures diverse pattern capture despite training data overlap

While the models are designed for independence through offset training windows and separate normalization, some degree of correlation may persist due to shared metric behavior across time. The 10^-36 rate should be considered a strong theoretical bound rather than an empirical guarantee.

Host-Level Aggregation

Host-level anomaly detection employs a two-stage process:

anomaly_rate(t) = count(anomalous_metrics(t)) / total_metrics
host_anomaly = average(anomaly_rate(t - 5min, t)) ≥ threshold

For a typical 5,000-metric host with a 1% threshold:

P(false host anomaly) ≈ (5000 choose 50) × (10⁻³⁶)⁵⁰ ≈ 10⁻¹⁶⁵⁰

This probability is effectively zero for all practical purposes.

Design Analysis

Strengths of the Approach

  1. Computational Efficiency

    • O(n) complexity for anomaly detection per data point
    • Fixed memory footprint per metric (~18KB)
    • No floating-point storage overhead (bit embedding)
  2. Operational Simplicity

    • Zero-configuration deployment
    • No labeled training data required
    • Deterministic behavior across deployments
  3. Statistical Robustness

    • Exponential reduction in false positives through consensus
    • Adaptation to concept drift via rolling window approach
    • Resistance to transient noise through multi-timescale validation
  4. Architectural Advantages

    • No network dependency for anomaly detection
    • No centralized processing bottleneck
    • Preserved data locality and privacy
  5. Root Cause Analysis Capabilities

    • Correlation engine identifies concurrent anomalies across all metrics
    • Scoring system ranks metrics by anomaly rate and persistence
    • Anomaly Advisor provides temporal correlation for incident investigation
    • Enables human-driven root cause analysis through comprehensive anomaly visibility
    • While individual anomaly detection is binary, the correlation engine uses anomaly counts and rates to prioritize metrics during investigation

Limitations and Trade-offs

  1. Temporal Coverage Constraints

    • 57-hour maximum pattern memory (configurable)
    • Inability to capture weekly/monthly seasonality (in the roadmap to support with user configuration)
    • Gradual degradation may evade detection if it occurs over the full window (in the roadmap to support with user configuration)
  2. Algorithm Simplicity

    • Binary classification (normal/anomalous) without confidence gradation (design choice)
    • Multiple anomaly patterns are detected but are not categorized (e.g., spike vs drift vs oscillation)
  3. Fixed Hyperparameters

    • Uniform 6-hour training windows regardless of metric characteristics (globally configurable)
    • Non-adaptive number of models per metric (globally configurable)
    • Static consensus requirement without metric-specific tuning (globally configurable)
  4. Detection Boundaries

    • Conservative bias may miss subtle anomalies
    • Cannot detect anomalies in missing data
    • Previously seen anomalous patterns become normalized

Anomaly Detection Capabilities

Detection Capability Summary

Anomaly TypeDescriptionDetected?Detection Mechanism
Point AnomaliesSudden spikes or drops exceeding historical boundsMin-max threshold at 99th percentile
Contextual AnomaliesNormal values in abnormal sequences6D feature space with temporal lags
Collective AnomaliesConcurrent anomalies across multiple metricsCorrelation engine and Anomaly Advisor
Change PointsSudden shifts to new normal levelsDetects transition, adapts within 3-57h
Concept DriftsGradual drift to new states⚠️Only if drift occurs within 57 hours
Rate-of-Change AnomaliesAbnormal acceleration/decelerationDifferenced values in feature vector
Short-term PatternsHourly/daily pattern violationsMultiple models capture different cycles
Weekly Patterns5-day work week behaviorsExceeds 57-hour memory window
Gradual DegradationSlow drift over 57+ hoursModels adapt to degradation as normal
Known Scheduled EventsBlack Friday, maintenance windowsWould require training exclusion

Detailed Analysis of Detection Capabilities

The current implementation effectively detects the following anomaly types:

  1. Point Anomalies (Strange Points)

    • Detection: Extreme values at or beyond historical training bounds trigger all 18 models
    • Examples:
      • Sudden spike in database failed transactions
      • Unexpected CPU utilization peak or memory spike
      • Single extreme values never seen in training windows
    • Mechanism: Min-max normalization ensures scores ≥99 for values exceeding training extremes
  2. Contextual Anomalies (Strange Patterns)

    • Detection: Normal values appearing in abnormal sequences are identified through temporal features
    • Examples:
      • Regular database backup job that fails to run (absence of expected pattern)
      • Capped web requests creating flat-line patterns
      • Unusual ordering of otherwise normal events
    • Mechanism: 6D feature space with 4 lagged values captures sequence context
  3. Collective Anomalies (Strange Multivariate Patterns)

    • Detection: Correlation engine identifies concurrent anomalies across related metrics
    • Examples:
      • Network issues causing retransmits while reducing throughput and database load
      • Cascading failures where individual metrics seem normal but system behavior is anomalous
    • Mechanism: Anomaly Advisor correlates and ranks simultaneous anomalies across all metrics
  4. Change Points (Strange Steps)

    • Detection: Sudden shifts to new operating levels are detected during transition
    • Examples:
      • Faulty deployment reducing served workload
      • Configuration change establishing new performance baseline
      • Service degradation creating persistent new state
    • Mechanism: All models initially flag the change; newer models adapt within 3-57 hours
  5. Concept Drifts (Strange Trends) - Partially Detected

    • Detection: Only if drift completes within the 57-hour window
    • Examples detected:
      • Memory leaks developing over hours to 2 days
      • Attacks gradually increasing over 1-2 days
    • Examples NOT detected:
      • Slow memory leaks over weeks
      • Gradual latency increases over weeks
    • Mechanism: Older models detect drift from their baseline; limitation when drift exceeds window
  6. Rate-of-Change Anomalies

    • Detection: Abnormal acceleration or deceleration in metric movement
    • Examples:
      • Rapid traffic ramp-up during flash events
      • Sudden deceleration in request processing
    • Mechanism: Differenced values (current - previous) in feature vector capture rate changes

Anomalies Not Currently Detected

The following anomaly types cannot be reliably detected with the current fixed-window approach:

  1. Long-term Seasonal Patterns

    • Weekly business cycles (5-day work week patterns)
    • Monthly patterns (billing cycles, month-end processing)
    • Quarterly or annual seasonality
    • Solution via training profiles: Time-window specific models (e.g., "weekday" vs "weekend" profiles)
  2. Gradual Performance Degradation

    • Memory leaks developing over weeks
    • Slowly accumulating technical debt effects
    • Performance erosion exceeding the 54-hour window
    • Solution via training profiles: Longer training windows for stability-critical metrics
  3. Rare but Regular Events

    • Weekly maintenance windows
    • Monthly batch processing
    • Scheduled system updates
    • Solution via training profiles: Event-specific models activated by schedule
  4. Metric-Specific Patterns

    • Business metrics with unique cycles
    • Metrics with non-standard distributions
    • Specialized behavioral patterns
    • Solution via training profiles: Custom parameters per metric class
  5. Known Anomalous Periods

    • Black Friday traffic spikes
    • End-of-quarter processing loads
    • Planned scaling events
    • Solution via training profiles: Temporary model switching during known events

Critical Design Decisions

Decision 1: K-means with k=2

Rationale: The choice of k=2 reflects a fundamental philosophy prioritizing operational reliability over detection sophistication.

Alternatives considered:

  • Larger k values: Would require parameter tuning per metric type
  • DBSCAN: Density requirements vary significantly across metrics
  • Isolation Forest: Computational overhead and parameter sensitivity

Trade-off: Reduced anomaly classification granularity for guaranteed stability

Decision 2: Fixed (globally configurable) 18-Model Ensemble

Rationale: Balances memory usage, computational cost, and temporal coverage.

Mathematics:

  • 18 models × 3-hour offset = 54-hour span (with 3 additional hours for the newest model's window)
  • Oldest model: trained on data from 51-57 hours ago
  • Newest model: trained on data from 0-6 hours ago
  • Total coverage: ~57 hours of historical patterns

Trade-off: Limited long-term pattern recognition for predictable resource usage

Decision 3: Unanimous Consensus Requirement

Rationale: Extreme conservative bias eliminates virtually all false positives.

Alternative approaches:

  • Majority voting: Would increase sensitivity but introduce false positives
  • Weighted voting: Requires confidence scores not available in bit storage
  • Threshold-based: Would need per-metric tuning

Trade-off: Potential false negatives for near-certain true positive identification

Decision 4: Min-Max Normalization

Rationale: Distribution-agnostic approach works for any metric type.

Comparison to alternatives:

  • Z-score normalization: Assumes Gaussian distribution
  • Percentile-based: Computationally expensive for streaming data
  • MAD-based: Sensitive to outliers in training data

Trade-off: Less statistical rigor for universal applicability

Empirical Considerations

Resource Utilization

Based on implementation analysis:

  • CPU overhead: 2-5% of a single core for 10,000 metrics
  • Memory usage: ~180MB for 10,000 metrics (18KB per metric)
  • Disk I/O: Zero additional I/O (bit embedding in existing storage)
  • Network traffic: Zero (all computation local)

Accuracy Characteristics

False Positive Analysis:

  • Theoretical rate: 10^-36 per metric
  • Practical observation: No confirmed random false positives in production deployments
  • Environmental factors (power events, kernel updates) may cause correlated true anomalies misinterpreted as false positives

False Negative Analysis:

  • Gradual degradation over 54+ hours: High probability of missing
  • Sub-threshold anomalies: By design will not detect
  • Seasonal patterns beyond 54 hours: Cannot detect without external configuration

Operational Deployment Patterns

Analysis of the system in production environments reveals:

  1. Cold Start Behavior: 48-72 hour stabilization period with elevated anomaly rates
    • During this period, anomaly rates are naturally higher as models accumulate training data
    • Operational recommendation: Use ML data for observation rather than alerting during initial deployment
    • System reaches optimal accuracy after full model rotation (57 hours)
  2. Steady State: Consistent 10^-36 false positive rate after stabilization
  3. Adaptation Speed: 3-hour minimum to begin incorporating new patterns
  4. Memory Effect: Complete pattern forgetting in 57 hours

Comparative Assessment

When evaluated against alternative approaches:

AspectNetdata MLStatistical (3σ)Deep LearningCommercial APM
False Positive Rate10^-360.3%VariableTypically 0.1-1%
Configuration RequiredNoneMinimalExtensiveModerate to High
Resource Overhead2-5% CPU<1% CPU30-60% CPUUnknown
Pattern Memory57 hours
(configurable)
UnlimitedModel-dependentDays to Weeks
Adaptation Speed3 hours
(configurable)
ImmediateRetraining requiredHours to Days
Metric CoverageALL metricsSelected metricsSelected metricsSelected metrics
ML EnablementAutomaticManual per metricManual trainingManual/Paid tier
Infrastructure Level Outage DetectionAutomaticNoNoNo
Correlation DiscoveryAutomaticNoLimitedManual/Limited

Critical Distinctions:

  1. Universal Coverage: Netdata applies ML anomaly detection to every single metric collected (typically 3,000-20,000 per server) without configuration or additional cost. Commercial APMs typically require manual selection of metrics for ML analysis, often limit the number of ML-enabled metrics, and may charge additional fees for ML capabilities.

  2. Infrastructure-Level Intelligence: Netdata automatically calculates host-level anomaly rates, detecting when a server exhibits abnormal behavior across multiple metrics. This capability identifies infrastructure-wide issues that metric-by-metric approaches miss.

  3. Automatic Correlation Discovery: During incidents, Netdata's correlation engine automatically identifies which metrics are anomalous together, revealing hidden relationships and cascading failures. Commercial solutions typically require manual investigation or pre-configured correlation rules.

These fundamental differences mean Netdata can detect both obvious infrastructure failures and subtle, complex issues automatically, while other solutions may miss issues in non-monitored metrics or fail to identify systemic problems.

Conclusions

Netdata's ML implementation represents a deliberate optimization for operational reliability over detection sophistication. The mathematical foundation ensures extraordinarily low false positive rates at the cost of potentially missing subtle or long-term patterns.

The consensus mechanism's reduction of false positives to 10^-36 represents a significant achievement in practical anomaly detection, effectively eliminating random false insights while maintaining sensitivity to genuine infrastructure issues.

The Bottom Line

Netdata's ML is not a replacement for deep statistical analysis or business-intent monitoring. But it is, unequivocally, one of the most reliable, scalable, and maintenance-free anomaly detection engines for infrastructure and application metrics available today.

  • If you're running 20+ servers or a fleet of IoT/edge devices?
    This is your early warning system for unexpected behaviors.

  • Managing a complex microservice deployment with unpredictable patterns?
    Layer this in as the safety net that never sleeps.

  • Need to detect infrastructure problems without a team of data scientists?
    This gives you automated anomaly detection that actually works.

The system's strength lies in its ability to provide trustworthy anomaly detection and surface correlations and dependencies across components and applications, without configuration or tuning. The trade-offs — limited temporal memory, binary detection, and conservative thresholds — represent a careful balance between sensitivity and reliability, false positives and false negatives. These design choices ensure the system maintains its 10^-36 false positive rate while still catching meaningful infrastructure issues, working reliably out of the box without drowning you in false insights.

For environments requiring detection of weekly patterns or gradual degradation over months, you'll need supplementary approaches (we also plan to support this with additional configuration to define periodicity). But for detecting significant, unexpected behavioral changes in infrastructure metrics — the kind that actually break things — Netdata's ML delivers exceptional reliability with negligible overhead.

In short: Yes, you need it.
Not as your only monitoring tool — but as the one that makes all the others smarter.


Do you have any feedback for this page? If so, you can open a new issue on our netdata/learn repository.