Log template determination method and device, computer equipment, medium and product
By matching and replacing differential content in log templates, the problems of low clustering calculation efficiency and invalid template generation are solved, and efficient log template generation and storage resource optimization are achieved.
Patent Information
- Application Number
- CN202410915680.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-09
- Publication Date
- 2024-10-15
AI Technical Summary
When the existing technology processes log data, the clustering calculation process is inefficient and generates a large number of invalid log templates, resulting in a waste of storage resources.
By obtaining the target log data, segmenting words and matching the word segmentation list in the generated log template, identifying the difference content, performing replacement processing according to the optimization conditions, and generating a new log template to avoid the generation of invalid templates.
It improves the efficiency of log template generation, saves storage space, simplifies the processing process, and avoids the generation of invalid templates.
Smart Images

Figure CN118780261A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, and in particular to a method, device, computer equipment, medium and product for determining a log template. Background Art
[0002] With the popularity of the Internet and mobile devices, various applications and services have generated a large amount of log data. This data contains rich information, but also brings challenges in processing, analysis and storage.
[0003] In the related art, log data can be clustered by a clustering algorithm to determine a log template of the log data. For new log data, a log template that matches the new log data can be determined from existing log templates, wherein, if no match is found, the new log data is clustered to obtain a corresponding log template. However, due to the large amount of log data, a large number of clustering calculation processes will be generated when clustering the log data. Moreover, similar log templates may be clustered, or multiple invalid log templates may be clustered. A large number of clustering calculation processes will reduce the efficiency of log template generation, and a large number of invalid log templates will occupy additional storage space, resulting in a waste of storage resources. Summary of the invention
[0004] In view of the above problems, the present disclosure is proposed. The present disclosure provides a method, device, computer equipment, medium and product for determining a log template.
[0005] According to one aspect of the present disclosure, a method for determining a log template is provided, comprising:
[0006] Obtain target log data, segment the target log data, and obtain a segmentation list;
[0007] Determine a first log template that matches the word list of the target log data from the generated log templates; wherein the first log template includes some of the word lists in the word list;
[0008] Based on the word segmentation list, identifying the difference between the log content of the target log data and the template content of the first log template;
[0009] When it is determined that the first log template meets the optimization condition based on the content quantity of the difference content, the difference content in the first log template is replaced by a target symbol to obtain a second log template.
[0010] In addition, the method further includes: when it is determined based on the content quantity of the difference content that the first log template does not meet the optimization condition, creating a new log template for the target log data according to the log content.
[0011] In addition, according to one aspect of the present disclosure, determining that the first log template meets the optimization condition based on the content quantity of the difference content includes:
[0012] Determine the difference between the length of the log content and the content length of the difference content;
[0013] When the difference is less than a preset length threshold, it is determined that the first log template meets the optimization condition.
[0014] In addition, according to one aspect of the present disclosure, after determining the second log template as the log template of the target log data, the method further includes:
[0015] Determine the log template content except the target symbol in the second log template;
[0016] Based on the log template content, a keyword index of the second log template is determined; wherein the keyword index is used for log template matching of the next real-time log data.
[0017] In addition, according to one aspect of the present disclosure, determining a first log template matching the word segmentation list of the target log data in the generated log templates includes:
[0018] Determine one or more keywords of the target log data in the word segmentation list;
[0019] Based on each of the keywords, a first log template matching at least one of the keywords is determined from the generated log templates.
[0020] In addition, according to one aspect of the present disclosure, the target log data is real-time log data; the step of determining a first log template that matches the word list of the target log data in the generated log templates includes:
[0021] Based on the word segmentation list, determining a key character string list of the real-time log data;
[0022] Determine a target character string that meets the character string length requirement in the key character string list;
[0023] Find a log template that matches the target string;
[0024] When it is determined that no log template matching the target character string is found, a first log template matching the word segmentation list of the target log data is determined from among the generated log templates.
[0025] In addition, the method further includes: in the case where it is determined that a log template matching the target character string is found, determining the matching log template as the log template of the real-time log data.
[0026] In addition, according to one aspect of the present disclosure, determining a target string that meets the string length requirement in the key string list includes:
[0027] The key character string with the largest length in the key character string list is determined as the target character string that meets the character string length requirement.
[0028] In addition, the method further includes: compressing the target log data when it is detected that the target log data meets the compression condition.
[0029] In addition, according to one aspect of the present disclosure, when it is detected that the target log data meets the compression condition, compressing the target log data includes:
[0030] Determine the number of occurrences of the log body residual words of the target log data within a preset time period; wherein the log body residual words are the difference content between the target log data and the second log template;
[0031] When it is determined that the number of times is greater than or equal to a preset number threshold, mapping compression processing is performed on the target log data based on the log body residual words to obtain the compressed target log data.
[0032] According to another aspect of the present disclosure, a device for determining a log template is provided, comprising:
[0033] The word segmentation module is used to obtain the target log data and segment the target log data to obtain a word segmentation list;
[0034] A matching module, configured to determine a first log template that matches the word list of the target log data from among the generated log templates; wherein the first log template includes some of the word lists in the word list;
[0035] an identification module, configured to identify differences between log content of the target log data and template content of the first log template based on the word segmentation list;
[0036] A replacement module is used to replace the difference content in the first log template with a target symbol to obtain a second log template when it is determined that the first log template meets the optimization condition based on the content quantity of the difference content, and determine the log template of the target log data based on the second log template.
[0037] According to another aspect of the present disclosure, a computer device is provided, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement steps of a method for determining a log template.
[0038] According to another aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program / instruction is stored. When the computer program / instruction is executed by a processor, the steps of a method for determining a log template are implemented.
[0039] According to another aspect of the present disclosure, a computer program product is provided, including a computer program / instruction, which implements the steps of a method for determining a log template when the computer program / instruction is executed by a processor.
[0040] As will be described in detail below, according to a method, apparatus, computer equipment, medium and product for determining a log template according to an embodiment of the present disclosure, first, target log data is acquired, and the target log data is segmented to obtain a segmentation list; secondly, a first log template matching the segmentation list of the target log data is determined in the generated log template; wherein the first log template includes some segmentations in the segmentation list; secondly, based on the segmentation list, the difference content between the log content of the target log data and the template content of the first log template is identified; finally, when it is determined that the first log template meets the optimization conditions based on the amount of content of the difference content, the difference content in the first log template is replaced by the target symbol to obtain a second log template.
[0041] By determining the word segmentation list of the target log data, the first log template that matches the target log data is determined in the generated log templates. And the first log template is replaced according to the difference between the first log template and the target log data to obtain the second log template corresponding to the target log data. In this embodiment, in the process of determining the second log template of the target log data, no calculation is required, the process is simple and the generation efficiency is high. And, in the case where the first log template needs to be optimized, the first log template is optimized based on the difference content. The first log template is replaced to obtain the second log template, and no new log template is generated, thereby avoiding the generation of a large number of invalid log templates and saving storage space.
[0042] It is to be understood that both the foregoing general description and the following detailed description are exemplary, and are intended to provide further explanation of the technology as claimed. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The above and other purposes, features and advantages of the present disclosure will become more apparent by describing the embodiments of the present disclosure in more detail in conjunction with the accompanying drawings. The accompanying drawings are used to provide a further understanding of the embodiments of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. In the accompanying drawings, the same reference numerals generally represent the same components or steps.
[0044] Figure 1 A flow chart of a method for determining a log template provided by an embodiment of the present disclosure is shown.
[0045] Figure 2 A schematic diagram of a new log template of a log template determination method provided by an embodiment of the present disclosure is shown.
[0046] Figure 3 A flowchart of determining a first log template in a method for determining a log template provided by an embodiment of the present disclosure is shown.
[0047] Figure 4 A specific flow chart of a method for determining a log template provided by an embodiment of the present disclosure is shown.
[0048] Figure 5 A schematic diagram of a log template determination device provided by an embodiment of the present disclosure is shown.
[0049] Figure 6 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the present disclosure more obvious, the exemplary embodiments according to the present disclosure will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all the embodiments of the present disclosure, and it should be understood that the present disclosure is not limited to the exemplary embodiments described here.
[0051] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0052] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.
[0053] Research has found that with the popularization of the Internet and mobile devices, various applications and services have generated a large amount of log data. This data contains rich information, but also brings challenges in processing, analysis and storage.
[0054] In the related art, log data can be clustered by a clustering algorithm to determine a log template of the log data. For new log data, a log template that matches the new log data can be determined from existing log templates, wherein, if no match is found, the new log data is clustered to obtain a corresponding log template. However, due to the large amount of log data, a large number of clustering calculation processes will be generated when clustering the log data. Moreover, similar log templates may be clustered, or multiple invalid log templates may be clustered. A large number of clustering calculation processes will reduce the efficiency of log template generation, and a large number of invalid log templates will occupy additional storage space, resulting in a waste of storage resources.
[0055] To facilitate understanding of this embodiment, a method for determining a log template disclosed in an embodiment of the present disclosure is first introduced in detail. The execution subject of the method for determining a log template provided in an embodiment of the present disclosure is generally an electronic device with certain computing capabilities. In some possible implementations, the method for determining a log template can be implemented by a processor calling a computer-readable instruction stored in a memory.
[0056] See also Figure 1 FIG. 1 is a flowchart of a method for determining a log template provided by an embodiment of the present disclosure, the method comprising steps S101 to S104, wherein:
[0057] S101: Obtain target log data, and segment the target log data to obtain a segmentation list.
[0058] In the embodiment of the present disclosure, first, the log body (ie, log content) of the target log data may be extracted, and then the log body may be segmented.
[0059] Here, the target log data can be segmented to obtain the segmentation time, log header and log body of the target log data, wherein the log header is used to indicate the generation information of the target log data, and the generation information includes at least one of the following: the generation time, generation address and log type of the target log data.
[0060] Here, you can set the word segmentation logic of the word segmenter in advance, and use the word segmenter to segment the target log data. For example, for the Chinese characters in the target log data, they are segmented into one word; for English words, they are segmented on a word-by-word basis; for numbers and floating-point numbers, they are not segmented; for English words connected by special symbols (i.e., "." or "-"), they are not segmented, for example, "org.apache.hadoop" and "java.io.IOException" are not segmented.
[0061] Here, after the target log data is segmented by the word segmenter, a segmentation list can be obtained: [log word 1, log word 2, ..., log word N], where N is the number of log words obtained after the target log data is segmented.
[0062] S102: Determine a first log template that matches the word segmentation list of target log data from among the generated log templates; wherein the first log template includes some of the word segmentations in the word segmentation list.
[0063] In an embodiment of the present disclosure, the first log template may be determined by the following steps: First, the length of the target log data may be determined. Second, a set of log templates whose length is greater than 1.5 times the log body length of the target log data may be determined as a log template subset of the target log data.
[0064] Finally, based on the word segmentation list, a log template whose longest common subsequence (LCS) length with the target log data is greater than or equal to 2 / 3 of the log body length of the target log data can be determined in the log template subset as the first log template, that is, the longest common subsequence between the word segmentation list and each log template in the log template subset is determined.
[0065] Here, if there are multiple log templates whose longest common subsequence length with the target log data is greater than or equal to 2 / 3 of the log body length of the target log data, the log template with the largest longest common subsequence length with the target log data is used as the first log template.
[0066] Here, if there is no log template in the log template subset whose longest common subsequence length with the target log data is greater than or equal to 2 / 3 of the log body length of the target log data, a new log template is created for the target log data according to the log content.
[0067] S103: Based on the word segmentation list, identify the difference between the log content of the target log data and the template content of the first log template.
[0068] In an embodiment of the present disclosure, the difference between the template content of the first log template and the word segmentation list may be determined.
[0069] Here, the content quantity of the difference content may be determined, thereby determining whether the first log template satisfies the optimization condition according to the content quantity of the difference content.
[0070] S104: When it is determined that the first log template meets the optimization condition based on the amount of the difference content, the difference content in the first log template is replaced by a target symbol to obtain a second log template.
[0071] In an embodiment of the present disclosure, the above steps determine that the first log template meets the optimization condition based on the content quantity of the difference content, and specifically include the following steps:
[0072] First, determine the difference between the length of the log content and the length of the difference content;
[0073] Then, when the difference is less than the preset length threshold, it is determined that the first log template meets the optimization condition.
[0074] In an embodiment of the present disclosure, the preset length threshold can be set to half the length of the log content, that is, when the difference between the length of the log content and the content length of the difference content is less than half the length of the log content, it is determined that the first log template meets the optimization condition.
[0075] Here, in the process of replacing the difference content in the first log data template with the target symbol, if the difference content between the template content and the word list is a word in a specific word library, the word will not be replaced with the target symbol. The target symbol can be represented by "*".
[0076] Here, in the case where multiple adjacent target symbols appear, the multiple adjacent target symbols can be merged into one target symbol to avoid the situation where multiple invalid templates appear due to different numbers of consecutive target symbols, occupying storage space.
[0077] Here, if the template content of the first log template changes, the first log template can be updated based on the changed template content, and the updated first log template is used as the second log template. When the second log template is obtained, the first log template can be deleted from the generated log templates.
[0078] In an embodiment of the present disclosure, first, target log data is acquired, and the target log data is segmented to obtain a segmentation list; secondly, a first log template that matches the segmentation list of the target log data is determined in the generated log template; wherein the first log template includes some segmentations in the segmentation list; secondly, based on the segmentation list, the difference content between the log content of the target log data and the template content of the first log template is identified; finally, when it is determined that the first log template meets the optimization condition based on the amount of content of the difference content, the difference content in the first log template is replaced by the target symbol to obtain a second log template.
[0079] In the above implementation, the first log template matching the target log data is determined in the generated log templates by determining the word segmentation list of the target log data. And the first log template is replaced according to the difference between the first log template and the target log data to obtain the second log template corresponding to the target log data. In this embodiment, in the process of determining the second log template of the target log data, no calculation is required, the process is simple and the generation efficiency is high. And, in the case where the first log template needs to be optimized, the first log template is optimized based on the difference content. The first log template is replaced to obtain the second log template, and no new log template is generated, thereby avoiding the generation of a large number of invalid log templates and saving storage space.
[0080] In an optional embodiment, the method further comprises the following steps:
[0081] In the case where it is determined based on the content quantity of the difference content that the first log template does not satisfy the optimization condition, a new log template is created for the target log data according to the log content.
[0082] In an embodiment of the present disclosure, when the difference between the length of the log content and the content length of the difference content is greater than or equal to a preset length, it is determined that the first log template does not meet the optimization condition.
[0083] Here, in the case where the first log template does not meet the optimization condition, a new log template may be determined based on the log ID, log length, and log content of the target log data.
[0084] See also Figure 2 As shown, it is a schematic diagram of a new log template of a method for determining a log template provided by an embodiment of the present disclosure, wherein:
[0085] id is used to record the log id of the target log data; ini_length is used to record the log length of the target log data; content is used to record the log content of the target log data; length is used to record the length of the log template generated by the target log data; position is used to record the position of the target symbol (that is, the position of the "*"); change is used to record the number of times the log template is replaced; regular is used to record whether the log template is fixed.
[0086] Here, when regular is false, it means that the log template can be replaced; when regular is true, it means that the log template cannot be replaced.
[0087] In an optional implementation, after determining the second log template as the log template of the target log data, the following steps are further included:
[0088] First, determine the log template content except the target symbol in the second log template;
[0089] Then, based on the log template content, a keyword index of the second log template is determined; wherein the keyword index is used for log template matching of the next real-time log data.
[0090] In an embodiment of the present disclosure, the log template content of the second log template may be segmented according to the target symbol, thereby obtaining the log template content.
[0091] Here, after obtaining the log template content, the log template content before and after the target is matched can be spliced to obtain the keyword index and the log information corresponding to the keyword index. The log information includes at least one of the following: the log id of the log template, the start position of the keyword index, the end position of the keyword index, and the length of the word segmenter.
[0092] Here, a keyword index dictionary may be generated based on the keyword indexes of multiple log templates. Based on the keyword index dictionary, the keyword indexes in the keyword index dictionary may be constructed into a data structure through an AC automaton (Aho-Corasick automaton).
[0093] Here, each node in the tree has a pointer to its child and a fail pointer. The fail pointer indicates the state to which the AC automaton should be transferred when the input character does not match any child node of the current node. The above steps can jump to the next possible matching position according to the guidance of the fail pointer, thereby improving the matching efficiency of the log template.
[0094] In an optional implementation, the above step of determining the first log template that matches the word segmentation list of the target log data in the generated log templates specifically includes the following steps:
[0095] First, one or more keywords of the target log data are determined in the word segmentation list;
[0096] Then, based on each keyword, a first log template matching at least one keyword is determined from the generated log templates.
[0097] In an embodiment of the present disclosure, an AC automaton may be used to perform inverted index processing on keywords, thereby determining a log template matching at least one keyword in the generated log templates to obtain a log template subset.
[0098] Here, after obtaining the log template subset, a first log template matching the word segmentation list of the target log data may be determined in the log template subset.
[0099] In an optional implementation, the target log data is real-time log data; the above step of determining the first log template that matches the word list of the target log data in the generated log templates specifically includes the following steps:
[0100] First, based on the word segmentation list, determine the key string list of real-time log data;
[0101] Secondly, determine the target string that meets the string length requirement in the key string list;
[0102] Secondly, find the log template that matches the target string;
[0103] Finally, when it is determined that no log template matching the target character string is found, a first log template matching the word segmentation list of the target log data is determined from the generated log templates.
[0104] In the embodiments of the present disclosure, the target log data may be real-time log data or historical log data.
[0105] Here, in the case where the target log data is historical log data, the above steps are not performed.
[0106] Here, the word segmentation list can be input into the AC automaton for processing, and the output of the AC automaton is determined as a key string list of the real-time log data, wherein the key string list includes the key string and the occurrence position of the key string.
[0107] Here, after the key character string list is determined, the key characters in the key character string list may be sorted in descending order according to their lengths.
[0108] Here, the above steps determine the target string that meets the string length requirement in the key string list, specifically including the following steps:
[0109] The key string with the largest length in the key string list is determined as the target string that meets the string length requirement.
[0110] In an embodiment of the present disclosure, the key character string that ranks first in the key character string list may be determined as a target character string that meets the character string length requirement.
[0111] Here, see Figure 3 As shown, it is a flowchart of determining a first log template in a method for determining a log template provided by an embodiment of the present disclosure, wherein:
[0112] First, a target string that meets the string length requirement may be determined in the key string list.
[0113] Secondly, based on the target string, the AC automaton can be used to search for a log template that matches the target string.
[0114] Secondly, it is determined whether a log template matching the target string can be found through the AC automaton based on the target string.
[0115] Secondly, when no log template matching the target string can be found through the AC automaton based on the target string, the target string can be deleted from the key string list.
[0116] Secondly, it is determined whether the key string list is an empty set. Secondly, if the key string list is not an empty set, the key string with the maximum length in the key string list is determined as the target string that meets the string length requirement, and a log template matching the target string is searched through the AC automaton based on the target string.
[0117] Secondly, when the key string list is an empty set and no log template matching the target string is found, a new log template can be created according to the log content of the target log data.
[0118] Secondly, determine whether the log template that matches the target string matches the word list of the target log data.
[0119] Secondly, if the log template matching the target string does not match the word segmentation list of the target log data, the target string is deleted from the key string list, and the key string with the largest length in the key string list is determined as the target string that meets the string length requirement, until a log template matching the target string can be found through the AC automaton based on the target string.
[0120] Finally, if the log template matching the target character string matches the word segmentation list of the target log data, the log template matching the target character string is used as the first log template.
[0121] In an embodiment of the present disclosure, when identifying the difference between the log content of the target log data and the template content of the first log template, only the log content other than the target character string in the target log data may be identified.
[0122] For example, when the log content of the target log data is "org.apache.hadoop Receiving emptypacket 34for 35" and the target string is "org.apache.hadoop Receiving empty packet", it is only necessary to identify whether "34for 35" satisfies the expression "*for*" in the first log template, which greatly reduces the amount of repeated calculations and improves time efficiency.
[0123] In an optional embodiment, the method further comprises the following steps:
[0124] When it is determined that a log template matching the target character string is found, the matching log template is determined as the log template of the real-time log data.
[0125] In an embodiment of the present disclosure, when it is determined that a log template matching the target string is found, that is, when the log template completely corresponds to the target log data, it is no longer necessary to identify the difference between the target log data and the log template, and the log template can be directly determined as the log template of the real-time log data.
[0126] Here, see Figure 4 As shown, it is a specific flow chart of a method for determining a log template provided by an embodiment of the present disclosure, wherein:
[0127] S10: Acquire real-time log data, and perform word segmentation processing on the real-time log data to obtain a word segmentation list.
[0128] S20: Based on the word segmentation list, determine a key string list of the real-time log data.
[0129] S30: Determine a target character string that meets the character string length requirement in the key character string list.
[0130] S40: Search for a log template that matches the target string.
[0131] S50: When it is determined that no log template matching the target character string is found, determine a first log template matching the word segmentation list of the target log data from among the generated log templates.
[0132] Here, if it is determined that no log template matching the target string is found, the real-time log data may be deduplicated. For example, if multiple identical real-time log data are generated at the same time, only one of the real-time log data is retained.
[0133] S60: Based on the word segmentation list, identify the difference between the log content of the target log data and the template content of the first log template.
[0134] S70 . When it is determined that the first log template meets the optimization condition based on the amount of the difference content, replace the difference content in the first log template with the target symbol to obtain a second log template.
[0135] In the above implementation, the first log template matching the target log data is determined in the generated log templates by determining the word segmentation list of the target log data. And the first log template is replaced according to the difference between the first log template and the target log data to obtain the second log template corresponding to the target log data. In this embodiment, in the process of determining the second log template of the target log data, no calculation is required, the process is simple and the generation efficiency is high. And, in the case where the first log template needs to be optimized, the first log template is optimized based on the difference content. The first log template is replaced to obtain the second log template, and no new log template is generated, thereby avoiding the generation of a large number of invalid log templates and saving storage space.
[0136] In an optional embodiment, the method further comprises the following steps:
[0137] First, when it is detected that the target log data meets the compression condition, compression processing is performed on the target log data.
[0138] In an embodiment of the present disclosure, whether the target log data needs to be stored in detail can be determined based on the service characteristics of the target log data. If the target log data does not need to be stored in detail, it is determined that the target log data meets the compression condition.
[0139] Here, before compressing the target log data, the log header and log body of the target log data can be determined first. The log header includes at least one of the following: log category, event source. During compression, only the log body is compressed without compressing the log header. The user can query the target log data or the second log template corresponding to the target log data by inputting the content in the log header.
[0140] In an optional implementation, the above step of compressing the target log data when it is detected that the target log data meets the compression condition includes:
[0141] First, the number of occurrences of the log body residual words of the target log data within a preset time period is determined; wherein the log body residual words are the difference content between the target log data and the second log template;
[0142] Then, when it is determined that the number of times is greater than or equal to the preset number threshold, mapping compression processing is performed on the target log data based on the log body residual words to obtain compressed target log data.
[0143] In an embodiment of the present disclosure, the difference content between the log body and the second log template may be determined and recorded.
[0144] Here, when it is determined that the length of the differentiated content is greater than a preset length threshold, the differentiated content may be used as a log body residual word.
[0145] Here, after determining that the number of times is greater than or equal to the preset number threshold, the log body residual word may be added to the log body residual word mapping dictionary table.
[0146] Here, the target log data may be mapped and compressed based on the log body residual word mapping dictionary table to obtain compressed target log data.
[0147] In an embodiment of the present disclosure, the following steps are also included to search the log data:
[0148] First, the search keyword can be obtained. Second, the log template can be searched according to the search keyword to determine the log template, log body residual words and log body differential content corresponding to the search keyword.
[0149] Secondly, a preliminary screening log data list may be determined by searching for log templates corresponding to the keywords, log body residual words, and log body differential content, wherein the similarity between the log data in the preliminary screening log data list and the search keywords is greater than a preset similarity threshold.
[0150] Finally, the log data with the greatest similarity can be used as the log data corresponding to the search keyword.
[0151] Here, the log template, log body residual words and log body differentiated content that meet the preset similarity threshold can be spliced to obtain the log data corresponding to the search keyword. Since this embodiment provides a log template search, it is beneficial for the search personnel or equipment to have an overall understanding of the log data, so the log data corresponding to the search keyword can be searched more accurately.
[0152] In the above, the method, apparatus, computer equipment, medium and product for determining a log template according to an embodiment of the present disclosure are described with reference to the accompanying drawings. The first log template matching the target log data is determined in the generated log template by determining the word segmentation list of the target log data. And the first log template is replaced according to the difference between the first log template and the target log data to obtain the second log template corresponding to the target log data. In this embodiment, in the process of determining the second log template of the target log data, no calculation is required, and the process is simple and the generation efficiency is high. Moreover, in the case where the first log template needs to be optimized, the first log template is optimized based on the difference content. The first log template is replaced to obtain the second log template, and no new log template is generated, thereby avoiding the generation of a large number of invalid log templates and saving storage space.
[0153] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0154] Based on the same inventive concept, the embodiment of the present disclosure also provides a device for determining a log template corresponding to the method for determining a log template. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the method for determining a log template in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0155] See also Figure 5 FIG. 1 is a schematic diagram of a log template determination device provided by an embodiment of the present disclosure, wherein the device comprises: a word segmentation module 11, a matching module 12, a recognition module 13, and a replacement module 14; wherein:
[0156] The word segmentation module is used to obtain the target log data and segment the target log data to obtain a word segmentation list;
[0157] A matching module, configured to determine a first log template that matches the word list of the target log data from among the generated log templates; wherein the first log template includes some of the word lists in the word list;
[0158] an identification module, configured to identify differences between log content of the target log data and template content of the first log template based on the word segmentation list;
[0159] A replacement module is used to replace the difference content in the first log template with a target symbol to obtain a second log template when it is determined that the first log template meets the optimization condition based on the content quantity of the difference content, and determine the log template of the target log data based on the second log template.
[0160] The disclosed embodiment determines the first log template that matches the target log data in the generated log templates by determining the word segmentation list of the target log data. And the first log template is replaced according to the difference between the first log template and the target log data to obtain the second log template corresponding to the target log data. In this embodiment, in the process of determining the second log template of the target log data, no calculation is required, and the process is simple and efficient. Moreover, in the case where the first log template needs to be optimized, the first log template is optimized based on the difference content. The first log template is replaced to obtain the second log template, and no new log template is generated, thereby avoiding the generation of a large number of invalid log templates and saving storage space.
[0161] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0162] Corresponds to Figure 1 The method for determining the log template in the embodiment of the present disclosure also provides an electronic device 600, such as Figure 6 FIG. 6 is a schematic diagram of the structure of an electronic device 600 provided in an embodiment of the present disclosure, including:
[0163] Processor 61, memory 62, and bus 63; memory 62 is used to store execution instructions, including internal memory 621 and external memory 622; the internal memory 621 is also called internal memory, which is used to temporarily store the operation data in the processor 61 and the data exchanged with the external memory 622 such as a hard disk. The processor 61 exchanges data with the external memory 622 through the internal memory 621. When the electronic device 600 is running, the processor 61 communicates with the memory 62 through the bus 63, so that the processor 61 executes the following instructions:
[0164] Obtain target log data, segment the target log data, and obtain a segmentation list;
[0165] Determine a first log template that matches the word list of the target log data from the generated log templates; wherein the first log template includes some of the word lists in the word list;
[0166] Based on the word segmentation list, identifying the difference between the log content of the target log data and the template content of the first log template;
[0167] When it is determined that the first log template meets the optimization condition based on the content quantity of the difference content, the difference content in the first log template is replaced by a target symbol to obtain a second log template.
[0168] The basic principles of the present disclosure are described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, effects, etc. mentioned in the present disclosure are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. are required by each embodiment of the present disclosure. In addition, the specific details disclosed above are only for the purpose of illustration and ease of understanding, and are not limitations. The above details do not limit the present disclosure to the necessity of adopting the above specific details to be implemented.
[0169] The block diagrams of the devices, apparatuses, equipment, and systems involved in this disclosure are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagrams. As will be appreciated by those skilled in the art, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including," "comprising," "having," and the like are open words, referring to "including but not limited to," and can be used interchangeably therewith. The words "or" and "and" used herein refer to the words "and / or," and can be used interchangeably therewith, unless the context clearly indicates otherwise. The word "such as" used herein refers to the phrase "such as but not limited to," and can be used interchangeably therewith.
[0170] Additionally, as used herein, "or" used in a list of items beginning with "at least one" indicates a separate list, so that, for example, a list of "at least one of A, B, or C" means A or B or C, or AB or AC or BC, or ABC (i.e., A and B and C). Furthermore, the word "exemplary" does not mean that the example described is preferred or better than other examples.
[0171] It should also be noted that in the system and method of the present disclosure, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present disclosure.
[0172] Various changes, substitutions, and modifications of the techniques described herein may be made without departing from the teachings defined by the appended claims. Furthermore, the scope of the claims of the present disclosure is not limited to the specific aspects of the processes, machines, manufactures, compositions of events, means, methods, and actions described above. Currently existing or later to be developed processes, machines, manufactures, compositions of events, means, methods, or actions that perform substantially the same functions or achieve substantially the same results as the corresponding aspects described herein may be utilized. Thus, the appended claims include such processes, machines, manufactures, compositions of events, means, methods, or actions within their scope.
[0173] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the aspects shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
[0174] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.
Claims
1. A method for determining a log template, characterized in that: include: Obtain target log data, segment the target log data, and obtain a segmentation list; Determine a first log template that matches the word list of the target log data from the generated log templates; wherein the first log template includes some of the word lists in the word list; Based on the word segmentation list, identifying the difference between the log content of the target log data and the template content of the first log template; When it is determined that the first log template meets the optimization condition based on the content quantity of the difference content, the difference content in the first log template is replaced by a target symbol to obtain a second log template.
2. The method according to claim 1, characterized in that The method further comprises: In a case where it is determined based on the content quantity of the difference content that the first log template does not satisfy the optimization condition, a new log template is created for the target log data according to the log content.
3. The method according to claim 1 or 2, characterized in that The determining, based on the content quantity of the difference content, that the first log template meets the optimization condition includes: Determine the difference between the length of the log content and the content length of the difference content; When the difference is less than a preset length threshold, it is determined that the first log template meets the optimization condition.
4. The method according to claim 1, characterized in that After determining the second log template as the log template of the target log data, the method further includes: Determine the log template content except the target symbol in the second log template; Based on the log template content, a keyword index of the second log template is determined; wherein the keyword index is used for log template matching of the next real-time log data.
5. The method according to claim 1, characterized in that The step of determining a first log template that matches the word segmentation list of the target log data from among the generated log templates includes: Determine one or more keywords of the target log data in the word segmentation list; Based on each of the keywords, a first log template matching at least one of the keywords is determined from the generated log templates.
6. The method according to claim 1, characterized in that The target log data is real-time log data; the step of determining a first log template that matches the word segmentation list of the target log data in the generated log templates includes: Based on the word segmentation list, determining a key character string list of the real-time log data; Determine a target character string that meets the character string length requirement in the key character string list; Find a log template that matches the target string; When it is determined that no log template matching the target character string is found, a first log template matching the word segmentation list of the target log data is determined from among the generated log templates.
7. The method according to claim 6, characterized in that The method further comprises: In the case where it is determined that a log template matching the target character string is found, the matching log template is determined as the log template of the real-time log data.
8. The method according to claim 6, characterized in that Determining a target string that meets the string length requirement in the key string list includes: The key character string with the largest length in the key character string list is determined as the target character string that meets the character string length requirement.
9. The method according to claim 1, characterized in that The method further comprises: When it is detected that the target log data meets the compression condition, compression processing is performed on the target log data.
10. The method according to claim 9, characterized in that When it is detected that the target log data meets the compression condition, compressing the target log data comprises: Determine the number of occurrences of the log body residual words of the target log data within a preset time period; wherein the log body residual words are the difference content between the target log data and the second log template; When it is determined that the number of times is greater than or equal to a preset number threshold, mapping compression processing is performed on the target log data based on the log body residual words to obtain the compressed target log data.
11. A device for determining a log template, characterized in that: include: The word segmentation module is used to obtain the target log data and segment the target log data to obtain a word segmentation list; A matching module, configured to determine a first log template that matches the word list of the target log data from among the generated log templates; wherein the first log template includes some of the word lists in the word list; an identification module, configured to identify differences between log content of the target log data and template content of the first log template based on the word segmentation list; A replacement module is used to replace the difference content in the first log template with a target symbol to obtain a second log template when it is determined that the first log template meets the optimization condition based on the content quantity of the difference content, and determine the log template of the target log data based on the second log template.
12. A computer device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method of claim 1.
13. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instructions are executed by a processor, the steps of the method according to claim 1 are implemented.
14. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to claim 1 are implemented.
Citation Information
Cited By
Log processing method and device, computer equipment, readable storage medium and program product
CN119647470A
