Abstract
Log parsing is a fundamental step in modern AIOps, transforming semi-structured raw logs into structured templates for downstream analysis. Traditional methods often force a trade-off between the high speed of syntax-based parsers and the semantic depth of Large Language Models (LLMs). This paper introduces LogParser-LLM, a hybrid framework that integrates a prefix parse tree with an LLM-based template extractor. By using the tree as a cache and router, the system processes millions of logs with minimal LLM API calls. Evaluated on the LogPub benchmark, LogParser-LLM achieves state-of-the-art accuracy while reducing processing time from weeks to minutes, effectively bridging the gap between semantic power and production efficiency.
Introduction
In the lifecycle of system monitoring, log parsing serves as the critical first step. It involves distinguishing between static templates (the fixed code structure) and dynamic parameters (variable data like IP addresses or status codes). While syntax-based parsers are efficient, they often struggle with the semantic complexity of rare error logs and require extensive manual tuning.
The Challenges of Modern Log Parsing
Existing log parsing solutions face three primary hurdles:
- The Efficiency Gap: Line-by-line LLM parsing is cost-prohibitive for high-volume production environments.
- The Granularity Problem: Parsing is often subjective; different tasks require different levels of detail in templates.
- Label Scarcity: Many neural models require large labeled datasets, which are unavailable for evolving systems.
Methodology: The Hybrid Prefix Tree Approach
LogParser-LLM addresses these challenges through a framework that centers on a Prefix Parse Tree acting as a router for an LLM Template Extractor.
Key Components
- Syntax Matching: When a new log arrives, the system first attempts to match it against the existing prefix tree. If a strict match is found, the log is clustered immediately without invoking the LLM.
- Variable-Aware Prompting (VA): For unmatched logs, the LLM is prompted to categorize variables into specific types (e.g., Object ID, Status Code) using a chain-of-thought approach, which significantly improves extraction accuracy.
- Automatic Merging: The system includes a mechanism to check if new logs can be merged into existing clusters by generalizing templates, preventing "template explosion."
- Granularity Distance (GD): A new metric inspired by edit distance allows users to quantify and calibrate the model's output to their specific needs (e.g., security vs. performance monitoring).
Evaluation and Results
The researchers evaluated LogParser-LLM on the LogPub benchmark, which contains 14 datasets averaging 3.6 million logs each.
- Efficiency: While a standard line-by-line LLM approach would take approximately 22 days to process the benchmark, LogParser-LLM completed the task in just 26 minutes using GPT-4. On average, it required only 272.5 API calls per 3.6 million logs.
- Accuracy: The model achieved a 90.6% F1 score for grouping accuracy and 81.1% for parsing accuracy, outperforming state-of-the-art models like Drain and LogPPT.
- Zero-Shot Performance: The system demonstrated exceptional "plug-and-play" capability, performing well across diverse systems without domain-specific training.
Conclusion
LogParser-LLM demonstrates that semantic understanding does not have to come at the cost of scalability. By leveraging the repetitive nature of logs through a prefix tree cache, the framework enables the use of powerful LLMs in high-throughput production environments. Future work will focus on optimizing smaller, open-source models like Llama-2 to further reduce costs while maintaining the high standards of semantic parsing set by GPT-4.
Summary updated