Improving log-based anomaly detection through learned adaptive filter

Yiyuan Xiong, Shaofeng CaiarXiv 2025 · DOI

Introduction

Modern software systems generate massive volumes of logs that serve as the primary "digital breadcrumbs" for troubleshooting and performance monitoring. To manage this scale, researchers have increasingly turned to unsupervised deep learning models, such as DeepLog and LogAnomaly, which treat log analysis as a natural language processing task. These models learn to predict the next likely log event based on historical sequences. However, a significant bottleneck remains in how these predictions are utilized to classify anomalies: the reliance on a static, "one-size-fits-all" threshold.

The Problem: The Static Threshold Bottleneck

The standard operating procedure for log-based anomaly detection involves a top-$k$ filter. If the actual next log event is among the model's top $k$ predictions, the behavior is labeled "normal"; otherwise, it is flagged as an "anomaly." Traditionally, engineers select a single, fixed value for $k$ (e.g., $k=10$) for the entire system. This approach suffers from three critical flaws:

  1. Dynamic Variance: Different system operations possess varying levels of predictability. A fixed $k$ may be too strict for complex, non-deterministic sequences (leading to false positives) or too lenient for simple, predictable ones (leading to false negatives).
  2. Manual Effort: Identifying the optimal $k$ requires exhaustive, time-consuming trial and error across different datasets.
  3. System Evolution: As software is updated and workloads shift, a hardcoded threshold quickly becomes obsolete, requiring constant recalibration.

Proposed Method: Learned Adaptive Filters

To address these limitations, this research introduces a Deep Reinforcement Learning (DRL) framework that replaces static thresholds with a Learned Adaptive Filter. By treating the selection of the filter value as a Markov Decision Process (MDP), the system can dynamically adjust its sensitivity based on the specific context of the log sequence.

The DRL Framework

The framework consists of several key components designed to optimize the detection process:

  • The Agent: A neural network that observes the current log sequence and determines the optimal filter value ($k$) for that specific moment.
  • State Representation: The agent evaluates the log sequence through three lenses: quantitative vectors (event frequency), sequential vectors (event order), and semantic vectors (the inherent meaning of the log text).
  • Action Space: The agent selects a value $k$ from a discrete set. To ensure computational efficiency during training, the authors implemented "structured action spaces," utilizing specific intervals or subsets of possible values.
  • Reward Function: To combat the inherent data imbalance in system logs—where 99% of data is typically normal—the authors utilized "reward shaping." The agent receives a significantly higher reward for correctly identifying a rare anomaly ($c=1.0$) compared to a normal sequence ($c=0.1$), forcing the model to prioritize critical failures.
  • Optimization: The framework utilizes Proximal Policy Optimization (PPO) and leverages the Ray RLlib library to facilitate parallel training across multiple CPU cores.

Experimental Evaluation

The framework was evaluated against two gold-standard industry benchmarks:

  1. HDFS: Logs from the Hadoop Distributed File System, containing over 11 million messages and 16,838 labeled aberrant blocks.
  2. BGL: Logs from a BlueGene/L supercomputer, spanning seven months and containing nearly 350,000 anomalous messages.

Key Results

The adaptive filter consistently outperformed fixed-configuration baselines across both datasets:

  • Significant Gains in BGL: On the BGL dataset, particularly in scenarios with limited training data, the RL-enhanced model achieved an F1-score of 0.51, a more than 100% improvement over the baseline score of 0.21.
  • Consistency in HDFS: In low-data scenarios on the HDFS dataset, the RL approach improved F1-scores from approximately 0.60 to a range of 0.70–0.78.
  • Robustness: The system demonstrated resilience to minor changes in hyperparameters, suggesting high viability for real-world deployment where perfect manual tuning is often impossible.

Discussion and Insights

A primary advantage of this approach is its orthogonality. Rather than replacing existing anomaly detectors, the DRL framework acts as an optimization layer that can be "plugged in" to improve almost any forecasting-based model. By allowing the filter to be fine-grained, the system becomes sensitive where necessary and relaxed during naturally noisy system operations.

However, some challenges remain. While the agent is highly efficient during inference (detection), the initial training phase can take several hours. Additionally, the agent's performance is ultimately capped by the quality of the underlying unsupervised model; if the base model cannot capture a pattern, the adaptive filter cannot compensate for that fundamental lack of information.

Conclusion

By shifting from static thresholds to learned, adaptive filters, this research provides a path toward more robust and autonomous system monitoring. Future work may involve moving toward an end-to-end RL pipeline where a single model handles both feature extraction and thresholding, further simplifying the log analysis workflow and reducing the need for manual intervention.

Summary updated

BibTeX
@misc{xiong2025improving,
  author = {Yiyuan Xiong and Shaofeng Cai},
  title = {{Improving log-based anomaly detection through learned adaptive filter}},
  year = {2025},
  eprint = {2504.02994},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.02994},
}
Figure