Home

Awesome

<p align="center"> <a href="https://github.com/logpai"> <img src="https://cdn.jsdelivr.net/gh/logpai/logpai.github.io@master/img/logpai_logo.jpg" width="480"></a></p>

Logparser

<div> <a href="https://pypi.org/project/logparser3"><img src="https://img.shields.io/badge/python-3.6+-blue" style="max-width: 100%;" alt="Python version"></a> <a href="https://pypi.org/project/logparser3"><img src="https://img.shields.io/pypi/v/logparser3.svg" style="max-width: 100%;" alt="Pypi version"></a> <a href="https://github.com/logpai/logparser/actions/workflows/ci.yml"><img src="https://github.com/logpai/logparser/workflows/CI/badge.svg?event=push" style="max-width: 100%;" alt="Pypi version"></a> <a href="https://pepy.tech/project/logparser3"><img src="https://static.pepy.tech/badge/logparser3" style="max-width: 100%;" alt="Downloads"></a> <a href="https://github.com/logpai/logparser/blob/main/LICENSE.md"><img src="https://img.shields.io/badge/license-view-brightgreen" style="max-width: 100%;" alt="License"></a> <a href="https://github.com/logpai/logparser#discussion"><img src="https://img.shields.io/badge/chat-wechat-brightgreen?style=flat" style="max-width: 100%;"></a> </div> <hr/> <div> <a href="https://github.com/logpai/logparser/stargazers"><img src="http://bytecrank.com/nastyox/reporoster/php/stargazersSVG.php?user=logpai&repo=logparser" width="600"/><a/> </div>

Logparser provides a machine learning toolkit and benchmarks for automated log parsing, which is a crucial step for structured log analytics. By applying logparser, users can automatically extract event templates from unstructured logs and convert raw log messages into a sequence of structured events. The process of log parsing is also known as message template extraction, log key extraction, or log message clustering in the literature.

<p align="center"><img src="https://cdn.jsdelivr.net/gh/logpai/logparser@main/docs/img/example.jpg" width="485"><br>An example of log parsing</p>

🌈 New updates

Log parsers available:

PublicationParserPaper TitleBenchmark
IPOM'03SLCTA Data Clustering Algorithm for Mining Patterns from Event Logs, by Risto Vaarandi.:arrow_upper_right:
QSIC'08AELAbstracting Execution Logs to Execution Events for Enterprise Applications, by Zhen Ming Jiang, Ahmed E. Hassan, Parminder Flora, Gilbert Hamann.:arrow_upper_right:
KDD'09IPLoMClustering Event Logs Using Iterative Partitioning, by Adetokunbo Makanju, A. Nur Zincir-Heywood, Evangelos E. Milios.:arrow_upper_right:
ICDM'09LKEExecution Anomaly Detection in Distributed Systems through Unstructured Log Analysis, by Qiang Fu, Jian-Guang Lou, Yi Wang, Jiang Li. [Microsoft]:arrow_upper_right:
MSR'10LFAAbstracting Log Lines to Log Event Types for Mining Software System Logs, by Meiyappan Nagappan, Mladen A. Vouk.:arrow_upper_right:
CIKM'11LogSigLogSig: Generating System Events from Raw Textual Logs, by Liang Tang, Tao Li, Chang-Shing Perng.:arrow_upper_right:
SCC'13SHISOIncremental Mining of System Log Format, by Masayoshi Mizutani.:arrow_upper_right:
CNSM'15LogClusterLogCluster - A Data Clustering and Pattern Mining Algorithm for Event Logs, by Risto Vaarandi, Mauno Pihelgas.:arrow_upper_right:
CNSM'15LenMaLength Matters: Clustering System Log Messages using Length of Words, by Keiichi Shima.:arrow_upper_right:
CIKM'16LogMineLogMine: Fast Pattern Recognition for Log Analytics, by Hossein Hamooni, Biplob Debnath, Jianwu Xu, Hui Zhang, Geoff Jiang, Adbullah Mueen. [NEC]:arrow_upper_right:
ICDM'16SpellSpell: Streaming Parsing of System Event Logs, by Min Du, Feifei Li.:arrow_upper_right:
ICWS'17DrainDrain: An Online Log Parsing Approach with Fixed Depth Tree, by Pinjia He, Jieming Zhu, Zibin Zheng, and Michael R. Lyu.:arrow_upper_right:
ICPC'18MoLFIA Search-based Approach for Accurate Identification of Log Message Formats, by Salma Messaoudi, Annibale Panichella, Domenico Bianculli, Lionel Briand, Raimondas Sasnauskas.:arrow_upper_right:
TSE'20LogramLogram: Efficient Log Parsing Using n-Gram Dictionaries, by Hetong Dai, Heng Li, Che-Shao Chen, Weiyi Shang, and Tse-Hsun (Peter) Chen.:arrow_upper_right:
ECML-PKDD'20NuLogSelf-Supervised Log Parsing, by Sasho Nedelkoski, Jasmin Bogatinovski, Alexander Acker, Jorge Cardoso, Odej Kao.:arrow_upper_right:
ICSME'22ULPAn Effective Approach for Parsing Large Log Files, by Issam Sedki, Abdelwahab Hamou-Lhadj, Otmane Ait-Mohamed, Mohammed A. Shehab.:arrow_upper_right:
TSC'23BrainBrain: Log Parsing with Bidirectional Parallel Tree, by Siyu Yu, Pinjia He, Ningjiang Chen, Yifan Wu.:arrow_upper_right:
ICSE'24DivLogDivLog: Log Parsing with Prompt Enhanced In-Context Learning, by Junjielong Xu, Ruichun Yang, Yintong Huo, Chengyu Zhang, and Pinjia He.:arrow_upper_right:

:bulb: Welcome to submit a PR to push your parser code to logparser and add your paper to the table.

Installation

We recommend installing the logparser package and requirements via pip install.

pip install logparser3

In particular, the package depends on the following requirements. Note that regex matching in Python is brittle, so we recommend fixing the regex library to version 2022.3.2.

Conditional requirements:

Get started

  1. Run the demo:

    For each log parser, we provide a demo to help you get started. Each demo shows the basic usage of a target log parser and the hyper-parameters to configure. For example, the following command shows how to run the demo for Drain.

    cd logparser/Drain
    python demo.py
    
  2. Run the benchmark:

    For each log parser, we provide a benchmark script to run log parsing on the loghub_2k datasets for evaluating parsing accuarcy. You can also use other benchmark datasets for log parsing.

    cd logparser/Drain 
    python benchmark.py
    

    The benchmarking results can be found at the readme file of each parser, e.g., https://github.com/logpai/logparser/tree/main/logparser/Drain#benchmark.

  3. Parse your own logs:

    It is easy to apply logparser to parsing your own log data. To do so, you need to install the logparser3 package first. Then you can develop your own script following the below code snippet to start log parsing. See the full example code at example/parse_your_own_logs.py.

    from logparser.Drain import LogParser
    
    input_dir = 'PATH_TO_LOGS/' # The input directory of log file
    output_dir = 'result/'  # The output directory of parsing results
    log_file = 'unknow.log'  # The input log file name
    log_format = '<Date> <Time> <Level>:<Content>' # Define log format to split message fields
    # Regular expression list for optional preprocessing (default: [])
    regex = [
        r'(/|)([0-9]+\.){3}[0-9]+(:[0-9]+|)(:|)' # IP
    ]
    st = 0.5  # Similarity threshold
    depth = 4  # Depth of all leaf nodes
    
    parser = LogParser(log_format, indir=input_dir, outdir=output_dir,  depth=depth, st=st, rex=regex)
    parser.parse(log_file)
    

    After running logparser, you can obtain extracted event templates and parsed structured logs in the output folder.

    • *_templates.csv (See example HDFS_2k.log_templates.csv)

      EventIdEventTemplateOccurrences
      dc2c74b7PacketResponder <> for block <> terminating311
      e3df2680Received block <> of size <> from <*>292
      09a53393Receiving block <> src: <> dest: <*>292
    • *_structured.csv (See example HDFS_2k.log_structured.csv)

      ...LevelContentEventIdEventTemplateParameterList
      ...INFOPacketResponder 1 for block blk_38865049064139660 terminatingdc2c74b7PacketResponder <> for block <> terminating['1', 'blk_38865049064139660']
      ...INFOReceived block blk_3587508140051953248 of size 67108864 from /10.251.42.84e3df2680Received block <> of size <> from <*>['blk_3587508140051953248', '67108864', '/10.251.42.84']
      ...INFOVerification succeeded for blk_-498091651989428962932777b38Verification succeeded for <*>['blk_-4980916519894289629']

Production use

The main goal of logparser is used for research and benchmark purpose. Researchers can use logparser as a code base to develop new log parsers while practitioners could assess the performance and scalability of current log parsing methods through our benchmarking. We strongly recommend practitioners to try logparser in your production environment. But be aware that the current implementation of logparser is far from ready for production use. Whereas we currently have no plan to do that, we do have a few suggestions for developers who want to build an intelligent production-level log parser.

🔥 Citation

If you use our logparser tools or benchmarking results in your publication, please cite the following papers.

🤗 Contributors

<!-- readme: contributors -start --> <table> <tr> <td align="center"> <a href="https://github.com/PinjiaHe"> <img src="https://avatars.githubusercontent.com/u/5793028?v=4" width="80;" alt="PinjiaHe"/> <br /> <sub><b>Pinjia He</b></sub> </a> </td> <td align="center"> <a href="https://github.com/zhujiem"> <img src="https://avatars.githubusercontent.com/u/7032227?v=4" width="80;" alt="zhujiem"/> <br /> <sub><b>Zhujiem</b></sub> </a> </td> <td align="center"> <a href="https://github.com/JinYang88"> <img src="https://avatars.githubusercontent.com/u/22317155?v=4" width="80;" alt="JinYang88"/> <br /> <sub><b>LIU, Jinyang</b></sub> </a> </td> <td align="center"> <a href="https://github.com/Siyuexi"> <img src="https://avatars.githubusercontent.com/u/50619651?v=4" width="80;" alt="Siyuexi"/> <br /> <sub><b>Junjielong Xu</b></sub> </a> </td> <td align="center"> <a href="https://github.com/ShilinHe"> <img src="https://avatars.githubusercontent.com/u/10590876?v=4" width="80;" alt="ShilinHe"/> <br /> <sub><b>Shilin HE</b></sub> </a> </td> <td align="center"> <a href="https://github.com/JoeHitHard"> <img src="https://avatars.githubusercontent.com/u/29425534?v=4" width="80;" alt="JoeHitHard"/> <br /> <sub><b>Joseph Hit Hard</b></sub> </a> </td></tr> <tr> <td align="center"> <a href="https://github.com/rustamtemirov"> <img src="https://avatars.githubusercontent.com/u/56340691?v=4" width="80;" alt="rustamtemirov"/> <br /> <sub><b>Rustam Temirov</b></sub> </a> </td> <td align="center"> <a href="https://github.com/gaiusyu"> <img src="https://avatars.githubusercontent.com/u/84389256?v=4" width="80;" alt="gaiusyu"/> <br /> <sub><b>Siyu Yu (Youth Yu)</b></sub> </a> </td> <td align="center"> <a href="https://github.com/thomasryck"> <img src="https://avatars.githubusercontent.com/u/37658138?v=4" width="80;" alt="thomasryck"/> <br /> <sub><b>Thomas Ryckeboer</b></sub> </a> </td> <td align="center"> <a href="https://github.com/IsuruBoyagane15"> <img src="https://avatars.githubusercontent.com/u/35162901?v=4" width="80;" alt="IsuruBoyagane15"/> <br /> <sub><b>Isuru Boyagane</b></sub> </a> </td></tr> </table> <!-- readme: contributors -end -->

Discussion

Welcome to join our WeChat group for any question and discussion. Alternatively, you can open an issue here.

Scan QR code