Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
logparser — 用于日志解析的机器学习工具包 [ICSE'19, DSN'16] | Kitploit
工具/GitHubGitHub/logpai/logparser
机器学习论文与研究异常检测日志分析
GitHublogpai/logparser

logparser

用于日志解析的机器学习工具包 [ICSE'19, DSN'16]

查看仓库
2.0k5791年前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

Logparser

Python 版本 Pypi 版本 Pypi 版本 下载量 许可证

Logparser 提供了一套用于自动化日志解析的机器学习工具包和基准测试,这是结构化日志分析中的关键步骤。通过使用 logparser,用户可以自动从非结构化日志中提取事件模板,并将原始日志消息转换为一系列结构化事件。在文献中,日志解析过程也称为消息模板提取、日志键提取或日志消息聚类。


日志解析示例

🌈 最新更新

  • 自 logparser 首次发布以来,由于与 Python 3 不兼容,许多 PR 和 issue 被提交。最终,我们更新了 logparser v1.0.0,使其支持 Python 3。感谢所有的贡献 (#PR86, #PR85, #PR83, #PR80, #PR65, #PR57, #PR53, #PR52, #PR51, #PR49, #PR18, #PR22)!
  • 我们构建了 wheel 包 logparser3,并将其发布到 pypi。请通过 pip install logparser3 安装。
  • 我们重构了代码结构,并通过 Python 代码格式化工具 black 美化了代码。

可用的日志解析器:

💡 欢迎提交 PR,将你的解析器代码加入 logparser,并将你的论文添加到表格中。

安装

我们建议通过 pip install 安装 logparser 包及其依赖。``` pip install logparser3

root@kitploit:~
具体来说,该软件包依赖以下要求。请注意,Python 中的 `regex` 匹配较为脆弱,因此我们建议将 regex 库固定为 2022.3.2 版本。

注意:如果您遇到 ``"Error: need to escape..."``,请按照[此处](https://github.com/logpai/logparser/issues/122)的说明操作。

+ python 3.6+
+ regex 2022.3.2
+ numpy
+ pandas
+ scipy
+ scikit-learn

条件要求:

+ 如果使用 MoLFI:`deap`
+ 如果使用 SHISO:`nltk`
+ 如果使用 SLCT:`gcc`
+ 如果使用 LogCluster:`perl`
+ 如果使用 NuLog:`torch`、`torchvision`、`keras_preprocessing`
+ 如果使用 DivLog:`openai`、`tiktoken`(需要 python 3.8+)

### 快速开始

1. 运行 demo:

    对于每个日志解析器,我们都提供了一个 demo 来帮助您快速上手。每个 demo 展示了目标日志解析器的基本用法以及需要配置的超参数。例如,以下命令演示了如何运行 Drain 的 demo。

    ```
    cd logparser/Drain
    python demo.py
    ```

2. 运行基准测试:
  
    对于每个日志解析器,我们都提供了一个基准测试脚本,用于在 [loghub_2k 数据集](https://github.com/logpai/logparser/tree/main/data#loghub_2k) 上运行日志解析,以评估解析准确率。您也可以使用[其他用于日志解析的基准数据集](https://github.com/logpai/logparser/tree/main/data#datasets)。

    ```
    cd logparser/Drain 
    python benchmark.py
    ```

    基准测试结果可在每个解析器的 readme 文件中找到,例如 https://github.com/logpai/logparser/tree/main/logparser/Drain#benchmark。

3. 解析您自己的日志:

    将 logparser 应用于解析您自己的日志数据非常简单。为此,您需要先安装 logparser3 软件包。然后,您可以按照下面的代码片段开发自己的脚本,开始日志解析。完整的示例代码请参见 [example/parse_your_own_logs.py](https://github.com/logpai/logparser/blob/main/example/parse_your_own_logs.py)。

    ```python
    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)
    ```

    运行 logparser 后,您可以在输出文件夹中获得提取的事件模板和解析后的结构化日志。

    + `*_templates.csv`(参见示例 [HDFS_2k.log_templates.csv](https://github.com/logpai/logparser/blob/main/logparser/Drain/demo_result/HDFS_2k.log_templates.csv))
    
        | EventId  | EventTemplate                                  | Occurrences |
        |----------|------------------------------------------------|-------------|
        | dc2c74b7 | PacketResponder <*> for block <*> terminating                                    | 311 |
        | e3df2680 | Received block <*> of size <*> from <*>                                          | 292 |
        | 09a53393 | Receiving block <*> src: <*> dest: <*>                                           | 292 |

    + `*_structured.csv`(参见示例 [HDFS_2k.log_structured.csv](https://github.com/logpai/logparser/blob/main/logparser/Drain/demo_result/HDFS_2k.log_structured.csv))
    
        | ... | Level | Content                                                                                       | EventId  | EventTemplate                                                       | ParameterList                              |
        |-----|-------|-----------------------------------------------------------------------------------------------|----------|---------------------------------------------------------------------|--------------------------------------------|
        | ... | INFO  | PacketResponder 1 for block blk_38865049064139660 terminating | dc2c74b7 | PacketResponder <*> for block <*> terminating | ['1', 'blk_38865049064139660'] |
        | ... | INFO  | Received block blk_3587508140051953248 of size 67108864 from /10.251.42.84                              | e3df2680 | Received block <*> of size <*> from <*>  | ['blk_3587508140051953248', '67108864', '/10.251.42.84']                                     |
        | ... | INFO  | Verification succeeded for blk_-4980916519894289629    | 32777b38 | Verification succeeded for <*> |  ['blk_-4980916519894289629']   |


### 生产环境使用
logparser 的主要目标是用于研究和基准测试目的。研究人员可以将 logparser 作为代码库来开发新的日志解析器,而从业者可以通过我们的基准测试评估当前日志解析方法的性能和可扩展性。我们强烈建议从业者在您的生产环境中尝试 logparser。但请注意,logparser 的当前实现远未达到可用于生产环境的标准。尽管我们目前没有这样做的计划,但我们确实为想要构建智能生产级日志解析器的开发者提供了一些建议。

+ 请注意 logparser 所使用的[第三方库的许可证](https://github.com/logpai/logparser/blob/main/LICENSE.md)。我们建议只保留一个解析器,删除其他解析器,然后重新构建软件包 wheel。这不会影响 logparser 的使用。
+ 请通过多进程处理来增强 logparser 的效率和可扩展性,添加故障恢复,并增加磁盘持久化或 Kafka 消息队列支持。
+ [Drain3](https://github.com/logpai/Drain3) 为您提供了一个很好的参考示例,它针对生产场景进行了[实用性增强](https://github.com/logpai/Drain3#new-features)。

### 🔥 引用
如果您在出版物中使用了我们的 logparser 工具或基准测试结果,请引用以下论文。

+ [**ICSE'19**] Jieming Zhu, Shilin He, Jinyang Liu, Pinjia He, Qi Xie, Zibin Zheng, Michael R. Lyu. [Tools and Benchmarks for Automated Log Parsing](https://arxiv.org/pdf/1811.03509.pdf). *International Conference on Software Engineering (ICSE)*, 2019.
+ [**DSN'16**] Pinjia He, Jieming Zhu, Shilin He, Jian Li, Michael R. Lyu. [An Evaluation Study on Log Parsing and Its Use in Log Mining](https://jiemingzhu.github.io/pub/pjhe_dsn2016.pdf). *IEEE/IFIP International Conference on Dependable Systems and Networks (DSN)*, 2016.


### 🤗 贡献者

<!-- readme: zhujiem,contributors -start -->
<table>
	<tbody>
		<tr>
            <td align="center">
                <a href="https://github.com/zhujiem">
                    <img src="https://assets.kitploit.com/production/public/readmes/51023/471767126e4450e42b40b8e3f5437c2d9d0616f468675dde6feccac1976b18d0/ee334336551226b1483445bee71089fdf5e61115652a2a99375e54566f34c9bf-display-v1.webp" width="80;" alt="zhujiem"/>
                    <br />
                    <sub><b>Zhujiem</b></sub>
                </a>
            </td>
            <td align="center">
                <a href="https://github.com/PinjiaHe">
                    <img src="https://assets.kitploit.com/production/public/readmes/51023/e9f83f96ab3d84e92152317c8d85d54a12fb0b0baea267d29e7d317a5caff94b/5b4a6af1bda6245edbb5c40ea1467625828536aeb88e984716753945b6235da2-display-v1.webp" width="80;" alt="PinjiaHe"/>
                    <br />
                    <sub><b>Pinjia He</b></sub>
                </a>
            </td>
            <td align="center">
                <a href="https://github.com/JinYang88">
                    <img src="https://assets.kitploit.com/production/public/readmes/51023/7785c7974d5753fa21792097907be1e20efb5fc5bbf3aba61b0b4d2f4fe26fec/19a47a39c4db07a8a052ed05304e166cca4cf18683d89a1400688c576ae48b52-display-v1.webp" 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://assets.kitploit.com/production/public/readmes/51023/fe7de7203a407b36e2f44a57603594e01266d124ef558b53cb95ba28afc6127c/f7a7173a142ced37b910b650e3ad957b27fcf2f13f4c828ff6a72fb87111435f-display-v1.webp" 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://assets.kitploit.com/production/public/readmes/51023/c8b37cadfeb622c955b807776ab0fa19f058c8ad512ebb22eb98c79ad5e90c17/fc476296c1b1aa6b1dd7c3220a81a1b70838d5c113a65e6b2f98196d0615b8a3-display-v1.webp" width="80;" alt="ShilinHe"/>
                    <br />
                    <sub><b>Shilin HE</b></sub>
                </a>
            </td>
            <td align="center">
                <a href="https://github.com/JosephMeghanathD">
                    <img src="https://assets.kitploit.com/production/public/readmes/51023/c2036c74a3116c7de955cae32687ffae61d8be46868cbcc61f771a7e9be4fa33/011ea30ec30f0db362d75632b310850b2783bd2c2428dfee7dc0fff182dc1bf8-display-v1.webp" width="80;" alt="JosephMeghanathD"/>
                    <br />
                    <sub><b>Joseph</b></sub>
                </a>
            </td>
		</tr>
		<tr>
            <td align="center">
                <a href="https://github.com/jcordon5">
                    <img src="https://assets.kitploit.com/production/public/readmes/51023/a4f67dd9f820a1dc763ae05e6d66ec6418d7e70abad8a9b5906413ab909f709e/4c8dc9fc08525d6d3c2334983160c0c9a48077fcc22b3498fe658aa133a2da02-display-v1.webp" width="80;" alt="jcordon5"/>
                    <br />
                    <sub><b>José A. Cordón </b></sub>
                </a>
            </td>
            <td align="center">
                <a href="https://github.com/rustamtemirov">
                    <img src="https://assets.kitploit.com/production/public/readmes/51023/3690f9e2cd318e8555a586fb32e221080e59e5de8917d82584da1f69e00be8cc/95300504879ab023f96e1cd73ca726c6720367b23e0d476e9a0b6cc23b89ff4d-display-v1.webp" 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://assets.kitploit.com/production/public/readmes/51023/68c5eeea49f8a2ee2cd39b633ed1fb9765cde38399b12636dea0a3dd0920c86d/8faa00619c5b17d96e80dff1b124695997ece681c0931519346fa0e62407c578-display-v1.webp" 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://assets.kitploit.com/production/public/readmes/51023/ad3710fbbe7106ffe560fe918f87e77a95a6bf7a21dbf65827f93138c96aca5a/ed736bf9ffd9aa54686cc7a3d404f7c0072ecaced2403ff467d112482255c2b3-display-v1.webp" 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://assets.kitploit.com/production/public/readmes/51023/dca9ea34301dd9441404246eb535a39d034518fd1311bebd68f1725bc38ba6b3/57b77cdaafca63553a32d53d83f1859d971c1628ef640c36ab1125939bb43a00-display-v1.webp" width="80;" alt="IsuruBoyagane15"/>
                    <br />
                    <sub><b>Isuru Boyagane</b></sub>
                </a>
            </td>
		</tr>
	<tbody>
</table>
<!-- readme: zhujiem,contributors -end -->

### 讨论
欢迎加入我们的微信群,提出任何问题或进行讨论。或者,您可以[在此处提交 issue](https://github.com/logpai/logparser/issues/new)。

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