Log event extraction method and system based on log tree and parse tree

Generate log trees through regular expressions and heuristic rule databases, and combine clustering technology to calculate the similarity between log trees and event trees, solving the problem of low accuracy in log event extraction in the existing technology, and achieving efficient and accurate logging Event extraction is suitable for anomaly detection and failure prediction of large-scale distributed systems.

CN113626400BActive Publication Date: 2024-11-29NANJING UNIV OF SCI & TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110781337.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-11
Publication Date
2024-11-29
Estimated Expiration
2041-07-11

AI Technical Summary

Technical Problem

Existing log event extraction methods are difficult to effectively utilize log internal structure information, resulting in low accuracy when processing heterogeneous logs, static fields are erroneously extracted as parameters, event granularity is too coarse, and manual definition of log format consumes a lot of labor costs.

Method used

Regular expressions and heuristic rule bases are used to automatically extract log formats, generate log trees, calculate the similarity between log trees and event trees through the longest common substring and the longest common subvector, and match the log trees and event trees with clustering technology. , extract events containing uncertain number of parameters.

Benefits of technology

It improves log preprocessing efficiency, accurately identify log internal structures, reduces matching time, improves event extraction accuracy, reduces the workload of manual log format recognition, and is suitable for abnormal detection and fault prediction of large-scale distributed systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113626400B_ABST
    Figure CN113626400B_ABST
Patent Text Reader

Abstract

The present invention discloses a log event extraction method and system based on log tree and parse tree. The method is divided into two steps: preprocessing and log content parsing, and specifically includes: proposing and maintaining a rule base composed of regular expressions and heuristic rules, extracting a small part of logs to automatically generate log formats; identifying logs as log headers and log contents online based on log formats; searching parse trees, using the longest common substring and the longest common subvector to respectively calculate the similarity of static fields and dynamic parameters in log trees and event trees; using clustering technology to match log trees and event trees, and extracting events and corresponding parameters. In order to cope with the complexity of log content, the present invention improves the preprocessing and log content parsing steps in the online event extraction method. Reduce the workload of manually identifying log formats, improve the problem that existing methods are difficult to identify events containing an indefinite number of parameters, and more accurately extract log events.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of log analysis event extraction, in particular to a log event extraction method and system based on a log tree and a parse tree. Background Art

[0002] With the rise of Internet technology and the expansion of computing and communication infrastructure, large-scale distributed systems have emerged. Logs are text data generated by the printout code embedded in the program, which records the current operating status and behavior patterns of the system. In the process of system development and maintenance, domain experts analyze logs to achieve real-time monitoring, anomaly detection, fault prediction and diagnosis of the system. The scale of logs is rapidly expanding, and it is difficult to efficiently identify new anomalies in the rapidly updated system and effectively troubleshoot system failures by manually analyzing logs alone. Therefore, log analysis has gradually changed from offline mode to online mode, and from manual analysis relying on domain experts to automatic analysis.

[0003] Event extraction is an important part of log analysis. It extracts parameters from log events and raw logs to provide structured data and key information for downstream log analysis. Raw logs include log headers with fixed fields such as timestamps and levels, and log content that describes the current state and behavior of the system. The main object of event extraction is log content. Before formally parsing the log content, preprocessing filters log headers with variable field values ​​but relatively fixed field types to reduce their interference with event extraction results. Common preprocessing divides log headers and log content based on manually defined log formats and identifies each field in the header. However, large-scale distributed systems often correspond to multiple heterogeneous logs, and redefining different log formats will consume a lot of labor costs.

[0004] The structure of log content is loose and complex, and it is difficult to extract it directly by conventional classification or clustering technology. Traditional log event extraction methods extract log events based on domain knowledge, which is difficult to quickly cope with the changing heterogeneous logs. The latest research adopts a combination of heuristic rules and clustering to improve event extraction methods. A group of logs corresponding to an event have the same static fields and similar log structures. Heuristic rules are usually based on the observation of a large number of log structures. Therefore, event extraction methods often use one or more heuristic rules to divide logs, accurately divide logs with similar structures into the same log group, and effectively improve the efficiency of the algorithm. After the division is completed, clustering operations are performed on each log group, and the qualified log clusters and corresponding log events are finally obtained by similarity calculation. This mode of combining heuristic rules with clustering abstracts the event extraction process into a parse tree. The internal nodes of the tree are usually the embodiment of the division of log groups by different heuristic rules, such as the number of log fields, the value of a certain field in the log, and so on. The leaf nodes store the final goal of event extraction obtained by clustering, that is, the log cluster represented as the event. By searching the parse tree, each preprocessed log is matched to the corresponding log cluster. However, existing event extraction methods formulate heuristic rules for global structural information such as the number of log fields or local content information such as log field categories, ignoring the internal structural information hidden between fields. After the log is matched to the log cluster, the fields of the log and event are compared, and the fields with different values ​​are directly replaced with wildcards, and the extracted values ​​are used as parameters to update the event. This method also ignores the internal structural information of the original log, which can easily lead to static fields being incorrectly extracted as parameters and the event granularity is too coarse. Summary of the invention

[0005] The present invention aims to provide a log event extraction method and system based on log tree and parse tree, which can mine the internal structure information of logs, and accurately extract the parameters in the events containing an indefinite number of parameters and the original log lines.

[0006] The technical solution to achieve the purpose of the present invention is: a log event extraction method based on a log tree and a parse tree, comprising:

[0007] Propose and maintain a rule base consisting of regular expressions and heuristic rules to extract a small part of the logs to automatically generate log formats;

[0008] Online identification of logs into log headers and log contents based on log formats;

[0009] Generate a log tree based on log structure information;

[0010] The parse tree is searched, and the longest common substring and the longest common subvector are used to calculate the similarity of static fields and dynamic parameters in the log tree and event tree respectively; clustering technology is used to match the log tree and event tree to extract events and corresponding parameters.

[0011] A log event extraction system based on log tree and parse tree, comprising:

[0012] The first module is used to propose and maintain a rule base consisting of regular expressions and heuristic rules to extract a small part of the logs and automatically generate the log format;

[0013] The second module identifies the log into log header and log content online based on the log format;

[0014] The third module generates a log tree based on the log structure information;

[0015] The fourth module searches the parse tree and uses the longest common substring and the longest common subvector to calculate the similarity between the static fields and dynamic parameters in the log tree and the event tree respectively; clustering technology is used to match the log tree and the event tree to extract events and corresponding parameters.

[0016] Compared with the prior art, the significant advantages of the present invention are: (1) automatically extracting log formats by constructing regular expressions and heuristic rule bases, reducing the workload of manual log format recognition and improving log preprocessing efficiency; (2) converting logs into log trees to fully utilize the internal structure of logs for event extraction and accurately identifying events containing an indefinite number of parameters; (3) searching for matching log trees based on parse trees, reducing matching time, improving matching accuracy, and extracting parameters from original log lines as input for downstream anomaly detection and fault prediction. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 The present invention is a flow chart of a log event extraction method based on a log tree and a parse tree. DETAILED DESCRIPTION

[0018] like Figure 1 As shown, a log event extraction method based on a log tree and a parse tree of the present invention adopts the following steps:

[0019] Step 1: Automatically identify the log format based on the rule base. This step extracts a small part of the logs and automatically generates the log format based on the heuristic rules and regular expressions in the rule base.

[0020] (1) Use spaces to split fields and perform alignment operations on the split fields;

[0021] (2) According to Rule 1, use the regular expression in the rule base to replace the identifiable fields. According to Rule 2, calculate the column complexity where the number of column fields is equal to the number of rows. Traverse the column fields to calculate the column complexity, the formula is as follows:

[0022]

[0023] In the formula, when a column is all the same value, the complexity of the column is 0; otherwise, the complexity of the column is the number of possible values.

[0024] (3) After calculating the column complexity, find the index with the largest complexity of 0 and the largest value according to Rule 3. max .

[0025] The rules and regular expressions in the rule base are as follows:

[0026] Rule 1: Some fields in the original heterogeneous log header, such as date, time, level, and number, can be defined based on limited regular expressions.

[0027] Rule 2. The header of each log has the same number of fields, and each field has the same type; the log content corresponding to different log lines has different numbers of fields, and each field type is not always the same. After aligning the log lines, calculate the complexity of each column.

[0028] Rule 3. The first field of the log content must appear after the column with complexity 0. Define index i For each column index, search for the index with the largest value and a complexity of 0. max , the first field index of the log content is index max+1 .

[0029] Regular expressions include various field types such as date, time, and level.

[0030] Step 2: Online preprocessing: Streaming logs are processed to identify log headers and log contents according to the log format. The log header includes timestamps, levels, or other fields.

[0031] (1) Split the log based on spaces to obtain fields.

[0032] (2) Identify each field of the log according to the field index of the log format. The log is divided into a log header containing a timestamp and other fields and a log content.

[0033] Step 3: Generate a log tree based on the log structure information. Use the structure information of hidden static fields and dynamic parameters to convert the log content into a log tree.

[0034] (1) Traverse the log from left to right. When the first field of the log contains ':' or is enclosed by '[]', the first field is recorded as the root node, which is also the indicator field of the log.

[0035] (2) The log is then divided into multiple fields based on ',' and spaces. Each field is matched with ':' from right to left. A subtree is created based on consecutive ':'s, and the field to the left of ':' is used as the parent node of the field to the right of ':'.

[0036] Step 4: Match the log tree based on the parse tree and update the event tree.

[0037] The structure of the parse tree is that the root node is a special tree node that does not contain an indicator field; the tree node contains an indicator field and a child node index; and the leaf node contains multiple log clusters corresponding to the same indicator field.

[0038] The process of matching the log tree is as follows:

[0039] (1) Search the indicator field of the parse tree. If the same indicator field is found, execute the next step; otherwise, create a new indicator field node and its log cluster child node.

[0040] (2) Search all candidate log clusters, calculate the similarity Sim between the log tree and the event tree, and select the log cluster corresponding to the maximum similarity after comparison. The similarity is determined by the static field similarity Sim s and dynamic parameter similarity Sim d Two parts, Sim = Sim s +Sim d The specific calculation steps are as follows:

[0041] (a) The first-level node fields of the log tree are denoted as L = {tl1, tl2, ..., tln}, and the number of fields contained in L is |L| = n. The first-level node fields of the event tree are denoted as E = {te1, te2, ..., tem}, and the number of fields contained in E is |E| = m.

[0042] (b) Static field similarity Common{L,E} uses the longest common substring (LCS) algorithm to obtain the longest common subfield of L and E.

[0043] (c) Dynamic parameter similarity Among them, L-Common{L,E} is the part of L that is not a common subfield between L and E, and E-Common{L,E} is the part of E that is not a common subfield between L and E. For the non-common fields of L and E, the longest common subvector (LCV) is used to obtain the non-common field vector VL of L and E = {vl1, vl2, ..., vl k} and VE={ve1,ve2,...,ve j}. k and j are the number of non-public fields of L and E respectively.

[0044] (3) Calculate the maximum similarity Sim maxAfterwards, it is compared with the similarity threshold St. When the similarity is greater than St, the log tree is matched successfully and the next step is executed; when the similarity is less than or equal to St, a new log cluster is created under the current indication node.

[0045] The process of updating the event tree is as follows:

[0046] (1) The root node of the event tree and the log tree has the same structure as the first-level node, storing static fields. The second-level and lower-level nodes store dynamic parameter fields and corresponding log IDs.

[0047] (2) When the log tree cannot be matched with any existing event tree, the log tree is directly converted into an event tree. The first-level nodes of the log tree remain unchanged, and the corresponding log ID is added to each node of the second and lower levels. The data in each node is saved in the form of (logId, data).

[0048] (3) When the log tree matches the existing event tree, merge the log tree and the event tree. The specific steps are as follows:

[0049] (a) Obtain the longest common field of all nodes in the first layer and retain the common field to the first layer of the event tree.

[0050] (b) The non-public field between two adjacent public fields is added to the event tree as a child node of the previous field, while retaining the log ID corresponding to the log tree. If the corresponding node already exists in the second layer, only (logId, data) needs to be added to the node of the old event tree to form a node of the new event tree.

[0051] Furthermore, the present invention also provides a log event extraction system based on a log tree and a parse tree, comprising:

[0052] The first module is used to propose and maintain a rule base consisting of regular expressions and heuristic rules to extract a small part of the logs and automatically generate the log format;

[0053] The second module identifies the log into log header and log content online based on the log format;

[0054] The third module generates a log tree based on the log structure information;

[0055] The fourth module searches the parse tree and uses the longest common substring and the longest common subvector to calculate the similarity between the static fields and dynamic parameters in the log tree and the event tree respectively; clustering technology is used to match the log tree and the event tree to extract events and corresponding parameters.

[0056] The specific implementation methods of the first to fourth modules are the same as the specific process of the log event extraction method, which will not be repeated here.

[0057] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A log event extraction method based on log tree and parse tree, It is characterized in that include: A rule base consisting of regular expressions and heuristic rules is proposed and maintained to extract a small part of the logs to automatically generate the log format. Specifically, the fields are separated by spaces and the separated fields are aligned. According to Rule 1, the identifiable fields are replaced with regular expressions in the rule base. According to Rule 2, the column complexity is calculated when the number of column fields is equal to the number of rows. After calculating the column complexity, the index with the largest complexity of 0 and the largest value is found according to Rule 3. max ; The rules and regular expressions in the rule base are as follows: Rule 1. Some fields in the original heterogeneous log header, including date, time, level, and number, are defined based on limited regular expressions; Rule 2. The header of each log has the same number of fields, and each field has the same type; the log content corresponding to different log lines has different numbers of fields, and each field type is not always the same; after aligning the log lines, calculate the complexity of each column; Rule 3. The first field of the log content must appear after the column with complexity 0; define index i For each column index, search for the index with the largest value and a complexity of 0. max , the first field index of the log content is index max+1 Identify the log into log header and log content online based on the log format. Specifically, the log is split based on spaces to obtain fields, and each field of the log is identified according to the field index of the log format. The log is divided into a log header including timestamp and other fields and log content. Generate a log tree based on the log structure information, traverse the log from left to right, and when the first field of the log contains ':' or is enclosed by '[]', record the first field as the root node, which is also the indicator field of the log; then divide the log into multiple fields based on ',' and spaces, match each field with ':' from right to left, create a subtree based on consecutive ':', and use the field on the left of ':' as the parent node of the field on the right of ':'; Search the parse tree, use the longest common substring to calculate the similarity between the static fields in the log tree and the event tree, and use the longest common subvector to calculate the similarity between the dynamic parameters in the log tree and the event tree; use clustering technology to match the log tree and the event tree, and extract events and corresponding parameters; the details are as follows: Match the log tree based on the parse tree, and update the event tree based on the log tree after matching; search the indicator field of the parse tree, create a new indicator field node and its log cluster child node after searching for different indicator fields, otherwise search all candidate log clusters, calculate the similarity Sim between the log tree and the event tree, and select the log cluster corresponding to the maximum similarity after comparison; calculate the maximum similarity Sim max After that, it is compared with the similarity threshold St; when Sim max When it is less than or equal to St, a new log cluster is created under the current indicated node; when Sim max When it is greater than St, the log tree matches successfully and the log tree is merged with the event tree. When the log tree cannot match any existing event tree, the log tree is directly converted into an event tree.

2. A log event extraction system based on log tree and parse tree, It is characterized in that include: The first module is used to propose and maintain a rule base consisting of regular expressions and heuristic rules, extract a small part of the logs and automatically generate the log format, specifically: Use spaces to split fields and perform alignment operations on the split fields. According to rule 1, use regular expressions in the rule base to replace identifiable fields; according to rule 2, calculate the column complexity when the number of column fields is equal to the number of rows; traverse the column fields to calculate the column complexity. After calculating the column complexity, find the index with the largest complexity of 0 and the largest value according to rule 3. max ; The rules and regular expressions in the rule base are as follows: Rule 1. Some fields in the original heterogeneous log header, including date, time, level, and number, are defined based on limited regular expressions; Rule 2. The header of each log has the same number of fields, and each field has the same type; the log content corresponding to different log lines has different numbers of fields, and each field type is not always the same; after aligning the log lines, calculate the complexity of each column; Rule 3. The first field of the log content must appear after the column with complexity 0; define index i For each column index, search for the index with the largest value and a complexity of 0. max , the first field index of the log content is index max+1 ; The second module is to identify the log into log header and log content online based on the log format, specifically: The log is split based on spaces to obtain fields, and each field of the log is identified according to the field index of the log format; the log is divided into a log header containing timestamps and other fields and log content; The third module generates a log tree based on the log structure information and traverses the log from left to right. When the first field of the log contains ':' or is enclosed by '[]', the first field is recorded as the root node, which is also the indicator field of the log. Then the log is divided into multiple fields according to ',' and spaces. Each field matches ':' from right to left. A subtree is created based on consecutive ':', and the field to the left of ':' is used as the parent node of the field to the right of ':'. The fourth module searches the parsing tree, uses the longest common substring to calculate the similarity between the static fields in the log tree and the event tree, and uses the longest common subvector to calculate the similarity between the dynamic parameters in the log tree and the event tree; uses clustering technology to match the log tree and the event tree, and extracts events and corresponding parameters; specifically: Match the log tree based on the parse tree, and update the event tree based on the log tree after matching; search the indicator field of the parse tree, create a new indicator field node and its log cluster child node after searching for different indicator fields, otherwise search all candidate log clusters, calculate the similarity Sim between the log tree and the event tree, and select the log cluster corresponding to the maximum similarity after comparison; calculate the maximum similarity Sim max After that, it is compared with the similarity threshold St; when Sim max When it is less than or equal to St, a new log cluster is created under the current indicated node; when Sim max When it is greater than St, the log tree matches successfully and the log tree is merged with the event tree. When the log tree cannot match any existing event tree, the log tree is directly converted into an event tree.

Citation Information

Patent Citations

  • Log parsing method and log parsing node device

    CN102164050A

  • Log clustering method based on graph structure

    CN105468677A