Skip to main content

Isolationforest Processor

Status Available in: contrib Maintainers: @atoulme, @aarvee11 Source: opentelemetry-collector-contrib

Supported Telemetry

Logs Metrics Traces

Overview

✨ Key Features


⚙️ How it Works

  1. Training window – The processor keeps up to window_size of the most recent data points for every feature‑group.
  2. Periodic (re‑)training – Every training_interval, it draws subsample_size points from that window and grows forest_size random isolation trees.
  3. Scoring – Each new point is pushed through the forest. Shorter average path length ⇒ higher anomaly score.
  4. Adaptive sizing – When enabled, window size automatically adjusts based on traffic velocity, memory usage, and model stability.
  5. Post‑processing
    • If add_anomaly_score: true, a gauge metric iforest.anomaly_score is emitted with identical attributes/timestamp.
    • If the score ≥ anomaly_threshold, the original span/metric/log is flagged with iforest.is_anomaly=true.
    • If drop_anomalous_data: true, flagged items are removed from the batch instead of being forwarded.
Contamination rate – instead of hard‑coding anomaly_threshold, you can supply contamination_rate (expected % of outliers). The processor then auto‑derives a dynamic threshold equal to the (1 – contamination_rate) quantile of recent scores.
Performance is linear in forest_size and logarithmic in window_size; a default of 100 trees and a 1 k‑point window easily sustains 10–50 k points/s on a vCPU.

🔧 Configuration

🔄 Adaptive Window Configuration

When enabled, the processor automatically adjusts window size based on traffic patterns and resource constraints: See the sample below for context.

📄 Sample config.yml

Note: Use routingconnector to seggregate the different kind of spans(db, messaging etc.) and send them to separate isolationforestprocessor deployments so the anomaly detection is pertianing to the respective category of signals.

What the example does


🚀 Best Practices

  • Tune forest_size vs. latency – start with 100 trees; raise to 200–300 if scores look noisy.
  • Use per‑entity models – add features (service, pod, host) to avoid global comparisons across very different series.
  • Let contamination drive threshold – set contamination_rate to the % of traffic you’re comfortable labelling outlier; avoid hand‑tuning anomaly_threshold.
  • Use adaptive window sizing – enable for dynamic workloads; the processor will automatically grow windows during high traffic and shrink under memory pressure.
  • Route anomalies – keep drop_anomalous_data=false and add a simple [routing‑processor] downstream to ship anomalies to a dedicated exporter or topic.
  • Monitor model health – the emitted iforest.anomaly_score metric is perfect for a Grafana panel; watch its distribution and adapt window / contamination accordingly.

🏗️ Internals (High‑Level)

Training cost: O(current_window_size × forest_size × log subsample_size) every training_interval Scoring cost: O(forest_size × log subsample_size) per item Note: With adaptive window sizing enabled, current_window_size dynamically adjusts between min_window_size and max_window_size based on traffic patterns and memory constraints, making training costs adaptive to workload conditions.

🤝 Contributing

  • Bugs / Questions – please open an issue in the fork first.
  • Recently added: Adaptive window sizing for dynamic traffic patterns.
  • Planned enhancements
    • Multivariate scoring (multiple numeric attributes per point).
    • Expose Prometheus counters for training time / CPU cost.
PRs welcome – please include unit tests and doc updates.

Configuration

Example Configuration


Last generated: 2026-08-24