CodeAD:利用大语言模型合成基于日志的异常检测规则代码
CodeAD: Synthesize Code of Rules for Log-based Anomaly Detection with LLMs
AI总结:
针对日志异常检测中可解释性与效率的挑战,本文提出CodeAD框架,利用大语言模型自动合成轻量级Python规则,通过层次聚类与智能体迭代优化,在三个数据集上F1平均提升3.6%,速度提升4倍,成本低于4美元。
摘要:
基于日志的异常检测(LogAD)对于维护大规模在线服务系统的可靠性和可用性至关重要。尽管基于机器学习、深度学习和大语言模型(LLMs)的方法推动了LogAD的发展,但它们常常面临可解释性有限、推理成本高以及预处理需求繁琐等问题,限制了其在实时、高吞吐量日志分析中的实用性。相比之下,基于规则的系统具有高效和透明的优势,但需要大量人工投入,且难以在多样化和不断变化的环境中扩展。在本文中,我们提出了CodeAD,一种新颖的框架,利用LLMs自动为LogAD合成轻量级的Python规则函数。CodeAD引入了一种层次聚类和锚点采样策略来构建具有代表性的对比日志窗口,使LLMs能够识别判别性的异常模式。为确保鲁棒性和泛化能力,CodeAD采用了一种智能体工作流,迭代地生成、测试、修复和优化规则,直到满足正确性和抽象性要求。合成的规则具有可解释性、轻量级,并可直接在原始日志上执行,支持高效且透明的在线异常检测。我们在三个公开数据集(BGL、Hadoop、Thunderbird)上进行的全面实验表明,CodeAD相比最先进的基线方法,F1分数平均绝对提升了3.6%,同时处理大数据集的速度最高提升4倍,且成本极低(每个数据集的LLM总调用成本低于4美元)。这些结果凸显了CodeAD作为在线监控系统的一种实用且可扩展的解决方案,能够在真实环境中实现可解释、高效且自动化的LogAD。
英文摘要:
Log-based anomaly detection (LogAD) is critical for maintaining the reliability and availability of large-scale online service systems. While machine learning, deep learning, and large language models (LLMs)-based methods have advanced the LogAD, they often suffer from limited interpretability, high inference costs, and extensive preprocessing requirements, limiting their practicality for real-time, high-volume log analysis. In contrast, rule-based systems offer efficiency and transparency, but require significant manual effort and are difficult to scale across diverse and evolving environments. In this paper, We present CodeAD, a novel framework that automatically synthesizes lightweight Python rule functions for LogAD using LLMs. CodeAD introduces a hierarchical clustering and anchor-grounded sampling strategy to construct representative contrastive log windows, enabling LLMs to discern discriminative anomaly patterns. To ensure robustness and generalizability, CodeAD employs an agentic workflow that iteratively generates, tests, repairs, and refines the rules until it meets correctness and abstraction requirements. The synthesized rules are interpretable, lightweight, and directly executable on raw logs, supporting efficient and transparent online anomaly detection. Our comprehensive experiments on three public datasets (BGL, Hadoop, Thunderbird) demonstrate that CodeAD achieves an average absolute improvement of 3.6% F1 score over the state-of-the-art baselines, while processing large datasets up to 4x faster and at a fraction of the cost (total LLM invocation cost under 4 USD per dataset). These results highlight CodeAD as a practical and scalable solution for online monitoring systems, enabling interpretable, efficient, and automated LogAD in real-world environment.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。