Interpretable Online Log Analysis Using Large Language Models with Prompt Strategies

Yilun Liu, Shimin Tao, Weibin Meng, Jingyu Wang, Wenbing Ma, Yuhang Chen, Yanqing Zhao, Hao Yang, Yanfei Jiang

TL;DR

This paper introduces LogPrompt, a novel approach that leverages Large Language Models (LLMs) for interpretable online log analysis. By employing advanced prompt strategies, LogPrompt achieves state-of-the-art performance on log parsing and anomaly detection without requiring in-domain training data, while also providing human-readable explanations for its predictions.

What Problem Does This Paper Address?

Modern software systems generate massive amounts of log data, making manual analysis time-consuming and error-prone. Existing automated log analysis methods, like log parsing and anomaly detection, often fall short in two critical areas:

  1. Online Scenarios & Data Scarcity: These methods typically require substantial amounts of in-domain training data. However, in real-world scenarios, software is constantly updated, leading to new log formats and a scarcity of historical data for training. This data inefficiency causes a sharp decline in performance, sometimes by over 60%, when encountering unseen logs from new domains.
  2. Limited Interpretability: Current methods provide single predictions (e.g., a parsed log template or an anomaly flag) without explanations. This lack of transparency hinders engineers' ability to understand the system's status, trust the results, and take appropriate actions.

The paper aims to address these challenges by developing an interpretable log analysis approach that is highly adaptive to online scenarios and provides clear justifications for its findings.

Methods

LogPrompt leverages Large Language Models (LLMs) and introduces a suite of advanced prompt strategies tailored for log analysis tasks. The core idea is to guide LLMs to perform log parsing and anomaly detection without extensive fine-tuning on domain-specific data.

Key methodological components include:

  • Prompt Engineering: The paper emphasizes that the effectiveness of LLMs in log analysis heavily relies on how prompts are designed. They propose three main prompt strategies:
  • Self-Prompt: LLMs are prompted to generate their own optimal prompts for a given task.
  • Chain-of-Thought (CoT) Prompt: This strategy encourages LLMs to break down complex reasoning into intermediate steps, leading to more logical and accurate outputs, especially for anomaly detection.
  • In-Context Prompt: LLMs learn from a few provided examples (log-label pairs) to understand the task and make predictions, enabling quick adaptation to new scenarios.
  • Format Controls: To ensure consistent and reliable output from LLMs, LogPrompt implements input and answer control functions. These functions structure the input logs and regulate the format of the generated explanations and predictions.
  • Interpretable Output: Beyond just predictions, LogPrompt is designed to generate human-readable explanations for its findings, aiding in program comprehension.

Datasets

The paper evaluates LogPrompt on nine publicly available real-world log datasets from diverse domains, including:

  • HDFS
  • Hadoop
  • HPC
  • Zookeeper
  • BGL
  • Linux
  • Proxifier
  • Android
  • Spirit

These datasets were used for both log parsing and anomaly detection tasks. For log parsing, templates were manually extracted from a subset of logs. For anomaly detection, two datasets (BGL and Spirit) were annotated by domain experts. The experiments simulate online scenarios by splitting datasets into training and testing sets chronologically, with LogPrompt being tested directly on unseen data.

Key Insights and Ideas

  • Prompting is Paramount: The performance of LLMs in log analysis is highly sensitive to prompt design. Simple prompts yield poor results, while carefully crafted strategies can boost performance significantly (up to 380.7%).
  • No In-Domain Training Needed: LogPrompt demonstrates that LLMs, when prompted effectively, can achieve state-of-the-art performance in log analysis without requiring any in-domain training data. This is a major advantage for online scenarios with evolving log formats.
  • Interpretability is Achievable and Valuable: The generated explanations from LogPrompt were highly rated by experienced practitioners for their usefulness and readability, significantly aiding in log analysis and program comprehension.
  • CoT Improves Accuracy: The Chain-of-Thought prompting strategy, even in its implicit form (requiring justifications), significantly improves the accuracy of anomaly detection by guiding the LLM's reasoning process.
  • Smaller LLMs Can Be Effective: LogPrompt is compatible with smaller, open-source LLMs, making it more accessible and reproducible for practical deployment.

Key Results

  • Log Parsing: LogPrompt achieved the best F1-score on six out of eight datasets, outperforming existing methods by up to 37.4% on average, despite not using in-domain training data.
  • Anomaly Detection: LogPrompt achieved an average improvement of 55.9% in F1-score compared to existing methods that were trained on thousands of logs.
  • Human Evaluation: Six experienced practitioners rated LogPrompt's explanations as highly useful and readable, with average scores consistently exceeding 4 out of 5. Over 80% of the generated explanations were considered highly interpretable.
  • Prompt Strategy Impact: The CoT prompt strategy improved anomaly detection performance by up to 0.195 in session-level F1-score and 0.206 in template-level F1-score compared to a simple prompt.
  • LLM Compatibility: LogPrompt demonstrated significant performance improvements (average increase of 380.7% in F1-score) when used with a smaller, open-source LLM (Vicuna 13B) compared to a simple prompt.

Limitations and Future Work

  • Domain Knowledge Gaps: LLMs sometimes lack specific domain knowledge, leading to overly general interpretations of technical terms. This can be a limitation in understanding highly specialized logs.
  • Semantic Insufficiency in Logs: Very brief or code-heavy log entries can pose challenges for LLMs to generate meaningful explanations.
  • Labeling Errors: Public datasets may contain labeling errors, which can affect absolute performance metrics.
  • Underestimated Baselines: The experimental setup for baselines (training on limited data to simulate online scenarios) might underestimate their true potential if they were trained on more data.

Future work suggested includes:

  • Advancing LLM capabilities through domain adaptation techniques.
  • Validating LogPrompt on a wider range of LLMs.
  • Expanding prompt strategies to cover more log analysis tasks.
  • Improving the model's understanding of non-NLP patterns in logs.

Summary updated

BibTeX
@inproceedings{liu2023interpretable,
  author = {Yilun Liu and Shimin Tao and Weibin Meng and Jingyu Wang and Wenbing Ma and Yuhang Chen and Yanqing Zhao and Hao Yang and Yanfei Jiang},
  title = {{Interpretable Online Log Analysis Using Large Language Models with Prompt Strategies}},
  booktitle = {ICPC},
  year = {2023},
}
Figure