Log processing method, device, server and storage medium
By segmenting the logs to be processed and classifying the type model tree, the problem of low log positioning efficiency in the existing technology is solved, rapid positioning and maintenance of logs is achieved, and the efficiency of log search and maintenance is improved.
Patent Information
- Application Number
- CN202111186059.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-12
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2041-10-12
AI Technical Summary
The existing technology is inefficient and difficult to locate a large number of log files, making it difficult to quickly find the problem.
By segmenting the log to be processed, determining its length, classifying it using a preset type model tree, storing log identifiers and templates, and improving log positioning efficiency.
It realizes the rapid positioning and maintenance of logs, improves the efficiency of log search and maintenance, and reduces the tediousness of manual configuration and maintenance.
Smart Images

Figure CN113934701B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a log processing method, device, server and storage medium. Background Art
[0002] When technical personnel are developing services or troubleshooting a program product, they often check the logs of the program product to troubleshoot possible problems and optimize the program product to provide better services to users.
[0003] In the prior art, technicians would directly view the original logs recorded by the program product during its operation on the computer, or search the original logs through keyword retrieval on log collection tools such as elk to locate logs with possible problems, and determine the specific location of the program product failure based on the logs with problems.
[0004] However, in actual applications, directly retrieving the original logs can only easily find problems when the logs are obviously abnormal, and due to the large number of original log files, the positioning method of the existing technology is inefficient and difficult to locate. Summary of the invention
[0005] The embodiments of the present application provide a log processing method, device, server and storage medium to solve the problem that a large number of log files have low positioning efficiency and great positioning difficulty under the existing positioning method.
[0006] In a first aspect, an embodiment of the present application provides a log processing method, including:
[0007] Obtaining the pending log of the application, wherein the pending log is a log after regular optimization;
[0008] The log to be processed is split into at least two sub-logs, and the number of sub-logs is determined as the length of the log to be processed, wherein the splitting process includes any one of the following: splitting by space, splitting by comma, and splitting by line break;
[0009] According to the length of the log to be processed and the at least two sub-logs, a first log type of the log to be processed is determined in a preset type model tree, the root node of the type model tree includes multiple internal nodes, each internal node includes multiple prefix trees, the length of the log to be processed that can be stored under each internal node is different, and the leaf nodes under the multiple prefix trees under each internal node store log identifiers of different log types and corresponding log templates, the prefix tree includes N layers of child nodes, the N layers of child nodes correspond to prefixes from the first sub-log to the Nth sub-log in sequence, the value of N is less than or equal to the number of the sub-logs, and the leaf node is the child node of the last layer of the prefix tree;
[0010] The identifier of the log to be processed is stored in the storage space under the leaf node used to store the first log type.
[0011] In a possible design of the first aspect, the method further includes:
[0012] Combining the prefix part of each sub-log in the at least two sub-logs according to the segmentation order to obtain the target constant of the log to be processed;
[0013] Determining a second log type of the log to be processed according to a target constant of the log to be processed and a correspondence between a preset constant and a log type;
[0014] The identifier of the log to be processed is stored in the storage space corresponding to the second log type.
[0015] In this possible design, the method further includes:
[0016] A mapping relationship between the first log type and the second log type of the log to be processed is established.
[0017] In another possible design of the first aspect, determining the first log type of the log to be processed in a preset type model tree according to the length of the log to be processed and the at least two sub-logs includes:
[0018] According to the length of the log to be processed, determining a target internal node corresponding to the log to be processed among the multiple internal nodes;
[0019] According to the multiple sub-logs, determining a target leaf node corresponding to the log to be processed in multiple prefix trees under the target internal node;
[0020] According to the log type corresponding to the target leaf node, a first log type of the log to be processed is determined.
[0021] In this possible design, after determining, according to the length of the log to be processed, a target internal node corresponding to the log to be processed among the multiple internal nodes, the method further includes:
[0022] According to the multiple sub-logs, if a target leaf node corresponding to the log to be processed is not determined in the multiple prefix trees under the target internal node, a new leaf node is established under the target internal node as the target leaf node;
[0023] Establishing a new log type under the new leaf node corresponding to the target internal node;
[0024] The new log type under the new leaf node is determined as the first log type of the log to be processed.
[0025] Optionally, after determining the first log type of the log to be processed according to the log type corresponding to the target leaf node, the method further includes:
[0026] Calculate similarity between the multiple sub-logs and the log template stored under the target leaf node to obtain at least one log template whose similarity value is greater than a preset similarity threshold;
[0027] The identifier of the log to be processed is stored under the log template corresponding to the largest similarity value among the at least one similarity value.
[0028] Optionally, the method further includes:
[0029] Performing similarity calculations on the multiple sub-logs and the log templates stored under the target leaf node, and failing to obtain at least one log template having a similarity value greater than a preset similarity threshold;
[0030] Generate a new log template according to the sub-nodes of each layer in the prefix tree corresponding to the target leaf node and the target internal node;
[0031] The identifier of the log to be processed is stored under the new log template.
[0032] In another possible design of the first aspect, determining the second log type of the log to be processed according to the target constant of the log to be processed and the correspondence between the preset constant and the log type includes:
[0033] Performing correlation calculation based on the target constant of the log to be processed and the preset constant to obtain a correlation value;
[0034] If the correlation value is greater than a preset correlation threshold, the log type corresponding to the preset constant is determined as the second log type of the log to be processed.
[0035] In this possible design, after performing correlation calculation based on the target constant of the log to be processed and the preset constant to obtain a correlation value, the method further includes:
[0036] If the correlation value is less than or equal to the preset correlation threshold, the target constant corresponding to the log to be processed is used as a new preset constant;
[0037] A new log type is established according to the new preset constant, and the new log type is determined as the second log type of the log to be processed.
[0038] In a second aspect, an embodiment of the present application provides a log processing device, including: an acquisition module, a determination module, and a storage module;
[0039] The acquisition module is used to acquire the to-be-processed log of the application program, wherein the to-be-processed log is a log after regular optimization;
[0040] The determination module is used to split the log to be processed to obtain at least two sub-logs, and determine the number of sub-logs as the length of the log to be processed, the splitting process includes any one of the following: splitting by space, splitting by comma, and splitting by line break, and according to the length of the log to be processed and the at least two sub-logs, determine the first log type of the log to be processed in a preset type model tree, the root node of the type model tree includes multiple internal nodes, each internal node includes multiple prefix trees, the length of the log to be processed that can be stored under each internal node is different, and the leaf nodes under the multiple prefix trees under each internal node store log identifiers of different log types and corresponding log templates, the prefix tree includes N layers of child nodes, the N layers of child nodes correspond to prefixes from the first sub-log to the Nth sub-log in sequence, the value of N is less than or equal to the number of sub-logs, and the leaf node is the child node of the last layer of the prefix tree;
[0041] The storage module is used to store the identifier of the log to be processed in the storage space under the leaf node used to store the first log type.
[0042] In a possible design of the second aspect, the determining module is further used to:
[0043] Combining the prefix part of each sub-log in the at least two sub-logs according to the segmentation order to obtain the target constant of the log to be processed;
[0044] Determining a second log type of the log to be processed according to a target constant of the log to be processed and a correspondence between a preset constant and a log type;
[0045] The identifier of the log to be processed is stored in the storage space corresponding to the second log type.
[0046] In this possible design, the determining module is further used to:
[0047] A mapping relationship between the first log type and the second log type of the log to be processed is established.
[0048] In another possible design of the second aspect, the determination module determines the first log type of the log to be processed in a preset type model tree according to the length of the log to be processed and the at least two sub-logs, specifically for:
[0049] According to the length of the log to be processed, determining a target internal node corresponding to the log to be processed among the multiple internal nodes;
[0050] According to the multiple sub-logs, determining a target leaf node corresponding to the log to be processed in multiple prefix trees under the target internal node;
[0051] According to the log type corresponding to the target leaf node, a first log type of the log to be processed is determined.
[0052] In this possible design, the determining module is further used to:
[0053] According to the multiple sub-logs, if a target leaf node corresponding to the log to be processed is not determined in the multiple prefix trees under the target internal node, a new leaf node is established under the target internal node as the target leaf node;
[0054] Establishing a new log type under the new leaf node corresponding to the target internal node;
[0055] The new log type under the new leaf node is determined as the first log type of the log to be processed.
[0056] Optionally, the determining module is further used to:
[0057] Calculate similarity between the multiple sub-logs and the log template stored under the target leaf node to obtain at least one log template whose similarity value is greater than a preset similarity threshold;
[0058] The identifier of the log to be processed is stored under the log template corresponding to the largest similarity value among the at least one similarity value.
[0059] Optionally, the determining module is further used to:
[0060] Performing similarity calculations on the multiple sub-logs and the log templates stored under the target leaf node, and failing to obtain at least one log template having a similarity value greater than a preset similarity threshold;
[0061] Generate a new log template according to the sub-nodes of each layer in the prefix tree corresponding to the target leaf node and the target internal node;
[0062] The identifier of the log to be processed is stored under the new log template.
[0063] In another possible design of the second aspect, the determination module determines the second log type of the log to be processed according to the target constant of the log to be processed and the correspondence between the preset constant and the log type, specifically for:
[0064] Performing correlation calculation based on the target constant of the log to be processed and the preset constant to obtain a correlation value;
[0065] If the correlation value is greater than a preset correlation threshold, the log type corresponding to the preset constant is determined as the second log type of the log to be processed.
[0066] In this possible design, the determining module is further specifically used for:
[0067] If the correlation value is less than or equal to the preset correlation threshold, the target constant corresponding to the log to be processed is used as a new preset constant;
[0068] A new log type is established according to the new preset constant, and the new log type is determined as the second log type of the log to be processed.
[0069] In a third aspect, an embodiment of the present application provides a server, including: a processor and a memory;
[0070] The memory stores computer-executable instructions;
[0071] The processor executes the computer execution instruction so that the server executes the log processing method as described in the first aspect and various possible designs above.
[0072] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer execution instructions are stored. When the computer execution instructions are executed by a processor, they are used to implement the log processing method described in the first aspect and various possible designs.
[0073] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, is used to implement the log processing method as described in the first aspect and various possible designs above.
[0074] The log processing method, device, server and storage medium provided by the embodiment of the present application. The method obtains a to-be-processed log of an application program, the to-be-processed log is a regular optimized log, and performs segmentation processing on the to-be-processed log to obtain at least two sub-logs, and determines the number of sub-logs as the length of the to-be-processed log, the segmentation processing includes any of the following: segmentation by space, segmentation by comma, segmentation by line break, and then according to the length of the to-be-processed log and at least two sub-logs, the first log type of the to-be-processed log is determined in a preset type model tree, the root node of the type model tree includes multiple internal nodes, each internal node includes multiple prefix trees, the length of the to-be-processed log that can be stored under each internal node is different, the leaf nodes under the multiple prefix trees under each internal node store log identifiers and corresponding log templates of different log types, the prefix tree includes N layers of child nodes, the N layers of child nodes correspond to prefixes from the first sub-log to the Nth sub-log in sequence, the value of N is less than or equal to the number of sub-logs, the leaf node is the child node of the last layer of the prefix tree, and finally the identifier of the to-be-processed log is stored in the storage space under the leaf node for storing the first log type. In this technical solution, by classifying the logs according to the preset type model tree structure, when locating related logs later, the log locating efficiency is improved and the locating is relatively easy. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0076] Figure 1 A schematic diagram of an application scenario of the log processing method provided in an embodiment of the present application;
[0077] Figure 2 A flow chart of a first embodiment of a log processing method provided in an embodiment of the present application;
[0078] Figure 3 A schematic diagram of the structure of the type model tree provided in the embodiment of the present application;
[0079] Figure 4 A flow chart of a second embodiment of the log processing method provided in the embodiment of the present application;
[0080] Figure 5 A schematic diagram of the structure of the preset constants provided in the embodiment of the present application;
[0081] Figure 6 A flow chart of a third embodiment of the log processing method provided in the embodiment of the present application;
[0082] Figure 7 A flowchart of a fourth embodiment of the log processing method provided in the embodiment of the present application;
[0083] Figure 8 A schematic diagram of the structure of a log processing device provided in an embodiment of the present application;
[0084] Fig. 9 A schematic diagram of the structure of a server provided in an embodiment of the present application.
[0085] The above drawings have shown clear embodiments of the present disclosure, which will be described in more detail below. These drawings and text descriptions are not intended to limit the scope of the present disclosure in any way, but to illustrate the concepts of the present disclosure to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0086] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0087] Before introducing the embodiments of the present application, the background technology of the present application is first explained:
[0088] When technicians are developing services or troubleshooting a program product, they often check the logs of the program product to troubleshoot possible problems, optimize the program product, and provide better services to users. The technicians will directly check the original logs recorded by the program product during operation on the computer, or search the original logs by keyword search on log collection tools such as elk to locate the logs of possible problems, and determine the specific location of the program product failure based on the problematic logs.
[0089] After solving the problem, technicians usually configure alarms for certain key logs. Generally, alarms are configured based on log keywords. However, with the continuous iteration of the game business, anomalies continue to increase, and the number of log types is also increasing. It is very cumbersome to configure alarm rules for specific keywords every time, and it is easy to miss.
[0090] Currently, there is no mature solution for log classification. Some manufacturers provide elk to allow users to write query conditions and save query rules to achieve the classification effect of specific types of logs. Some applications also use deep learning, machine learning and other methods to perform clustering to achieve log classification.
[0091] Manually configuring rules requires the author to have more experience in elk, regular expressions, etc., and it is difficult to debug and maintain. It requires manual comparison of search results to ensure the correctness of the search conditions. Every time a new log type is added, the query rules need to be added and modified again, and the maintenance process is cumbersome. The performance of algorithms such as deep learning is far from being able to be implemented in the scenario of millions of queries per second (QPS) in the game business.
[0092] Based on the above problems existing in the prior art, Figure 1 The following is a schematic diagram of an application scenario of the log processing method provided in the embodiment of the present application, which is used to solve the above technical problems. Figure 1 As shown, the application scenario schematic diagram includes: a server 11 and a terminal device 12.
[0093] In one possible design, an application is installed on the terminal device 12. The user starts the application by clicking on the application icon. As the application runs, logs are continuously generated. The server 11 obtains the logs and classifies different logs according to the method provided in the embodiment of the present application. Log identifiers with similar templates are classified into the same category. When the technicians need to query the possible problems in the logs later, they look for the corresponding category and obtain the log identifier in the category. They further query the detailed log information corresponding to the log identifier to realize the entire process from log generation to log location.
[0094] In response to the above technical problems, the inventor's technical conception process of the present application is as follows: In the prior art, the volume of original logs is huge, and it is difficult to quickly locate the problem by directly searching the original logs. If the logs are classified and templates are generated, and the rules of the templates can be formed based on the first n tokens of the logs, the newly generated logs can also be quickly classified by the templates. When locating the logs later, templates of different categories can be quickly found, and the corresponding log identifier can be found under the template. Based on this, the efficiency of maintaining, locating and searching the logs is greatly improved.
[0095] Below Figure 1The application scenario schematic diagram shown in the figure describes the technical solution of the present application in detail through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0096] Figure 2 The following is a flow chart of the first embodiment of the log processing method provided in the present application. Figure 2 As shown, the log processing method may include the following steps:
[0097] Step 21: Get the pending logs of the application.
[0098] The logs to be processed are logs after regular optimization.
[0099] In this solution, when network devices, systems and service programs are operating, an event record named log will be generated. The log corresponding to each line of the event record records the description of related operations such as date, time, user and action.
[0100] Furthermore, when it is necessary to troubleshoot problems with network devices, systems or service programs in the future, it is necessary to find logs with possible problems from a large number of logs and browse or screen the information recorded in the logs to overcome possible problems with the network devices, systems or service programs.
[0101] In this step, in an actual production environment, the first few tokens of each log have the characteristics of a template. When the logs to be processed are classified according to the template, regular optimization is first performed on the logs to be processed.
[0102] Optionally, some words (such as numbers, etc.) in the log to be processed can be replaced with "*". It should be understood that the regular optimization method is only an example, and is only for the purpose of obtaining text that is easy to retrieve and replace and conforms to a certain pattern (rule). Therefore, the embodiments of the present application do not limit other preprocessing methods similar to regular optimization.
[0103] Step 22: Split the log to be processed into at least two sub-logs, and determine the number of sub-logs as the length of the log to be processed.
[0104] The segmentation process includes any of the following: segmentation by space, segmentation by comma, and segmentation by line break.
[0105] In this step, based on the log after regular optimization, the log to be processed is segmented to obtain sub-logs of multiple lengths, that is, multiple tokens.
[0106] Specifically, taking space segmentation as an example, a log to be processed is segmented by space to obtain 4 tokens, that is, 4 sub-logs, and the corresponding length of the log to be processed is 4.
[0107] As an example: Log 1: Receive from node 4, block blk_3587src: / 10.251.42.84:57069dest: / 10.251.42.84:50010.
[0108] As another example: Log 2: Receive from node 5, block blk_7174src: / 10.251.42.90:57069dest: / 10.251.42.90:50010.
[0109] Then, after splitting log 1 and log 2 by spaces, we can get Receive from node*, block*, src:*, dest:*, that is, a to-be-processed log with a length of 4, that is, 4 sub-logs.
[0110] Step 23: Determine a first log type of the log to be processed in a preset type model tree according to the length of the log to be processed and at least two sub-logs.
[0111] Among them, the root node of the type model tree includes multiple internal nodes, each internal node includes multiple prefix trees, the length of the log to be processed that can be stored under each internal node is different, and the leaf nodes under the multiple prefix trees under each internal node store log identifiers of different log types and corresponding log templates. The prefix tree contains N layers of child nodes, and the child nodes of the N layers correspond to the prefixes from the first sub-log to the Nth sub-log in sequence. The value of N is less than or equal to the number of sub-logs of the log to be processed, and the leaf node is the child node of the last layer of the prefix tree.
[0112] In this step, for the path from a certain leaf node to the internal node where the leaf node is located, the number of child nodes is less than or equal to the number of sub-logs, that is, starting from the first child node under the internal node, which corresponds to the prefix of the first sub-log, until the prefix of the Nth sub-log corresponding to the Nth child node, the number of sub-logs of the log to be processed may be greater than the number of child nodes, that is, the embodiment of the present application can dynamically adjust the number of sub-node layers contained in the prefix tree.
[0113] Optional, Figure 3 This is a schematic diagram of the structure of the type model tree provided in the embodiment of the present application. Figure 3As shown, the structural diagram includes: a root node 31, multiple internal nodes 32 (each internal node represents the length of different logs to be processed, for example, length: 4, length: 5...length: 10), and each internal node contains different tokens (subnodes 33). For example, the length 4 contains the subnodes of the first layer: send, receive, the length 5 contains the subnodes of the first layer: starting,...the length 10 contains: *.
[0114] Furthermore, under the first-layer child nodes such as send and receive, there may be respective second-layer child nodes, which diverge in a tree-like manner until the last-layer child nodes (leaf nodes).
[0115] For each leaf node, log identifiers of different log types and corresponding log templates are stored thereunder. For example, under the root node 31, the length is 4, and a list log group is stored under receive. In a list log, a log template and the identifier of the log that meets the log template can be stored.
[0116] For example, the log template is: Receive from node*; the log identifier of the log template is: 1, 23, 25, 46, 345, ... (the cache address of the log).
[0117] Optionally, according to the length of the log to be processed and at least two sub-logs (existing tokens), matching is performed in the type model tree. First, the target internal node is determined among multiple internal nodes according to the length of the log to be processed. Secondly, the target leaf node corresponding to the log to be processed is determined under the sub-nodes of each layer of multiple prefix trees according to at least two sub-logs. Under the target leaf node, a specific log template is determined, that is, the first log type corresponding to the log template is determined.
[0118] Step 24: Store the identifier of the log to be processed in the storage space under the leaf node for storing the first log type.
[0119] In this step, the first log type matching the log to be processed is found, and the identifier of the log to be processed is stored in the storage space under the leaf node of the first log type.
[0120] When subsequently querying or locating related logs, the user can check different first log types to roughly determine the log category to be queried, and then find the log identifier under the category. In a possible implementation, the user can click a button related to the log identifier to obtain the log.
[0121] The log processing method provided by the embodiment of the present application obtains a to-be-processed log of an application program, where the to-be-processed log is a regular optimized log, and performs segmentation processing on the to-be-processed log to obtain at least two sub-logs, and determines the number of sub-logs as the length of the to-be-processed log, wherein the segmentation processing includes any one of the following: segmentation by space, segmentation by comma, and segmentation by newline, and then determines the first log type of the to-be-processed log in a preset type model tree according to the length of the to-be-processed log and the at least two sub-logs, wherein the root node of the type model tree includes multiple internal nodes, each of which includes multiple prefix trees, and the length of the to-be-processed log that can be stored under each internal node is different, and the leaf nodes under the multiple prefix trees under each internal node store log identifiers of different log types and corresponding log templates, and the prefix tree includes N layers of child nodes, and the N layers of child nodes correspond to prefixes from the first sub-log to the Nth sub-log in sequence, and the value of N is less than or equal to the number of sub-logs, and the leaf node is the child node of the last layer of the prefix tree, and finally the identifier of the to-be-processed log is stored in the storage space under the leaf node for storing the first log type. In this technical solution, by classifying the logs according to the preset type model tree structure, when locating related logs later, the log locating efficiency is improved and the locating is relatively easy.
[0122] Based on the above embodiments, Figure 4 The following is a flow chart of the second embodiment of the log processing method provided in the present application. Figure 4 As shown, the log processing method may also include the following steps:
[0123] Step 41: Combine the prefix part of each sub-log in at least two sub-logs according to the segmentation order to obtain the target constant of the log to be processed.
[0124] In this step, in order to further improve the situation that logs of the same type are divided into different types of logs due to different lengths in the above division, this step uses the prefix part of the sub-log of the log to be processed as the target constant of the log to be processed, so as to classify the log to be processed.
[0125] Optionally, prefix parts of each sub-log in at least two sub-logs obtained by splitting the log to be processed by spaces are combined into a target constant.
[0126] In a possible implementation, log 2: Receive from node 5, block blk_7174src: / 10.251.42.90:57069dest: / 10.251.42.90:50010, then the target constant composed of the prefix part of the sub-log of log 2 is Receive from node*, block*, src:*, dest:*. Ignoring the limitation on the number of sub-logs in the above method, the prefix of each sub-log is directly matched in turn.
[0127] Step 42: Determine the second log type of the log to be processed according to the target constant of the log to be processed and the corresponding relationship between the preset constant and the log type.
[0128] In this step, the preset constant is a constant corresponding to the log template, which records the characteristics of the corresponding log type, including the prefix part of multiple sub-logs of the log, and is matched according to the target constant and the preset constant of the log to be processed to obtain the second log type.
[0129] Optional, Figure 5 This is a schematic diagram of the structure of the preset constants provided in the embodiment of the present application. Figure 5 As shown, the structural diagram includes: A1, B1, C1, D1 and E1.
[0130] Among them, taking the log template as a preset constant composed of 3 sub-log prefixes, and the log to be processed is the log type corresponding to the preset constant as an example, the prefix part of each sub-log of the log template is A1 (first prefix), B1 (second prefix) and C1 (third prefix), and the length of the log template is 3. Then, according to each field in the target constant, each prefix part A2, B2 and C2 in the log to be processed is matched in sequence.
[0131] In addition, D1 and E1 are the first prefix and the second prefix of other template logs.
[0132] When A1, B1, C1 and A2, B2 and C2 match one by one respectively, it is determined that the log type of the log to be processed is the log type corresponding to the preset constant, and is recorded as the second log type. This step is explained in detail in the following embodiment.
[0133] Step 43: Store the identifier of the log to be processed in the storage space corresponding to the second log type.
[0134] In this step, the second log type matching the log to be processed is found, and the identifier of the log to be processed is stored in the storage space corresponding to the second log type.
[0135] When subsequently querying or locating related logs, the user can check different second log types to roughly determine the log category to be queried, and then find the log identifier under the category. In a possible implementation, the user can click a button related to the log identifier to obtain the log.
[0136] Step 44: Establish a mapping relationship between the first log type and the second log type of the log to be processed.
[0137] In this step, the classification of the first log type includes the classification of the number of sub-logs of the log to be processed, that is, the log to be processed composed of different numbers of sub-logs has different internal nodes, and the classification of the second log type directly distinguishes the sub-logs, and its distinction is coarser than the classification of the first log type.
[0138] Optionally, the format of the identifier of the log to be processed corresponding to the first log type is matched to the identifier of the log to be processed corresponding to the second log type, and stored in the TemplateMap cache of the database, which can facilitate subsequent template searches.
[0139] The log processing method provided by the embodiment of the present application combines the prefix part of each sub-log in at least two sub-logs according to the segmentation order to obtain the target constant of the log to be processed, and then determines the second log type of the log to be processed according to the target constant of the log to be processed and the correspondence between the preset constant and the log type, and then stores the identifier of the log to be processed in the storage space corresponding to the second log type, and finally establishes the mapping relationship between the first log type and the second log type of the log to be processed. This technical solution realizes the classification of the log to be processed through the correspondence between the preset constant and the log type, and the log positioning efficiency is higher when the related logs are subsequently located.
[0140] Based on the above embodiments, Figure 6 The following is a flow chart of the third embodiment of the log processing method provided in the present application. Figure 6 As shown, the above step 23 may include the following steps:
[0141] Step 61: Determine a target internal node corresponding to the log to be processed from multiple internal nodes according to the length of the log to be processed.
[0142] In this embodiment, combined with Figure 3 , explain the relevant steps, the length of the log to be processed is the number of sub-logs of the log to be processed, and in the type model tree, the corresponding internal nodes are matched according to the number of sub-logs.
[0143] In one possible implementation, if the length of the log to be processed is 4, the internal node of "length: 4" in the type model tree is determined as the target internal node; if the length of the log to be processed is 10, the internal node of "length: 10" in the type model tree is determined as the target internal node.
[0144] In another possible implementation, if a target internal node corresponding to the log to be processed is not determined among multiple internal nodes according to the length of the log to be processed, an internal node with a new length is added as the target internal node.
[0145] In this possible implementation, the type model tree has the function of continuously adding new internal nodes. For example, initially 7 internal nodes with a length of 4-10 can be recorded, but if the number of sub-logs of some logs is more than 10 or less than 4, the internal nodes can be appropriately increased or decreased.
[0146] Step 62: According to the multiple sub-logs, determine the target leaf node corresponding to the log to be processed in the multiple prefix trees under the target internal node.
[0147] In this step, the multiple prefix trees under the target internal node may include child nodes of the first layer, child nodes of the second layer, child nodes of the third layer, ... child nodes (leaf nodes) of the Nth layer.
[0148] For example, under an internal node "length: 4", the internal node contains: the first-level child nodes (send, receive...), the first-level child node receive contains the second-level child nodes (from, to...), the second-level child node from contains the third-level child nodes (H, I, J), the third-level child node H contains the fourth-level child nodes (K, L), presenting a tree-like divergent structure.
[0149] Optionally, multiple sub-logs in the log to be processed are matched in order with each layer of child nodes in multiple prefix trees under the target internal node to determine the child node of the last layer (target leaf node), where the log template and log identifier are stored correspondingly.
[0150] In this step, there is another possibility: if the target leaf node corresponding to the log to be processed is not determined in the multiple prefix trees under the target internal node according to the multiple sub-logs, that is, under the target internal node in the type model tree, no corresponding sub-node is found for each sub-log in the log to be processed, then perform the following operations:
[0151] Step 1: Create a new leaf node under the target internal node as the target leaf node.
[0152] Optionally, if the first sub-log in the log to be processed does not match the first-layer child node in the target internal node, a new first-layer child node is established under the target internal node as the target first leaf node. Similarly, a new second-layer child node is established under the new first-layer child node, with the second sub-log in the log to be processed as the new second-layer child node, and the process is executed in sequence until the Nth-layer child node is established as the target leaf node.
[0153] In addition, if the Mth (M is less than or equal to N) sub-log in the log to be processed does not match the child node of the Mth layer in the prefix tree, the Mth sub-log in the log to be processed is used as the new child node of the Mth layer until the child node of the Nth layer is established as the target leaf node, and the path before the child node of the Mth layer and the child nodes between the M layer and the N layer are used as the path of the log to be processed.
[0154] Step 2: Create a new log type under the new leaf node corresponding to the target internal node.
[0155] Optionally, the log template corresponding to the new log type has the target internal node as the starting node, the new leaf node as the ending node, and the prefix of the sub-log corresponding to the path passed by the log to be processed as the new template, that is, the log type.
[0156] Step 3: Determine the new log type under the new leaf node as the first log type of the log to be processed.
[0157] Optionally, the new log type is the first log type of the log to be processed. Accordingly, the new log type has a log template corresponding to the new log type, and the log template corresponding to the new log type is stored.
[0158] In addition, if the sub-log token is a variable, the number of points will be infinitely expanded. In this case, a maxChild parameter can be introduced to limit the maximum number of leaf nodes for each internal node. When maxChild is reached, a <*> node will be generated under the leaf node. When subsequent logs do not match other leaf nodes, the <*> leaf node will be automatically matched.
[0159] Step 63: Determine the first log type of the log to be processed according to the log type corresponding to the target leaf node.
[0160] In this step, the leaf nodes cache log templates corresponding to their respective first log types. The log to be processed follows the path of the type model tree and continuously reaches the log type corresponding to the target leaf node through the above matching, thereby determining that the log type corresponding to the target leaf node is the first log type of the log to be processed.
[0161] Optionally, the log processing method may further include the following operations:
[0162] Step 1: Calculate similarity between multiple sub-logs and the log template stored under the target leaf node to obtain at least one log template whose similarity value is greater than a preset similarity threshold.
[0163] Optionally, in the target leaf node, the similarity of all templates is simSeq, and the template whose simSeq is greater than a preset similarity threshold st and whose simSeq value is the largest is returned.
[0164] The specific formula is:
[0165] Among them, seq1 is the log to be processed, seq2 is each template under the target leaf node, i is the i-th sub-log in the log to be processed, and n is the number of sub-logs of the log to be processed.
[0166] Before this, if no log template is stored under the target leaf node, the prefix of the sub-log on the path from the target internal node of the log to be processed to the target leaf node is used as a new log template.
[0167] Step 2: Store the identifier of the log to be processed under the log template corresponding to the largest similarity value among at least one similarity value.
[0168] Optionally, similarity values corresponding to log templates greater than a preset similarity threshold may be compared in a traversal manner to determine a larger similarity value among the preset similarity thresholds as the maximum similarity value.
[0169] Alternatively, the process may also include the following steps:
[0170] Step 1: perform similarity calculation based on multiple sub-logs and the log template stored under the target leaf node, and do not obtain a log template with at least one similarity value greater than a preset similarity threshold.
[0171] Optionally, after similarity matching, the matching results are that the similarity values are all less than or equal to a preset similarity threshold.
[0172] Step 2: Generate a new log template based on the child nodes at each level in the prefix tree corresponding to the target leaf node and the target internal node.
[0173] Optionally, prefixes of each sub-log of the log to be processed on the path to the target leaf node are used as components of the new log template.
[0174] Step 3: Store the ID of the log to be processed under the new log template.
[0175] The log processing method provided in the embodiment of the present application determines the target internal node corresponding to the log to be processed from multiple internal nodes according to the length of the log to be processed, and then determines the target leaf node corresponding to the log to be processed from multiple prefix trees under the target internal node according to multiple sub-logs, and then determines the first log type of the log to be processed according to the log type corresponding to the target leaf node. This technical solution provides a basis for classifying the log to be processed according to the first log type by determining the target leaf node corresponding to the log to be processed from multiple prefix trees.
[0176] Based on the above embodiments, Figure 7 The flowchart of the fourth embodiment of the log processing method provided in the embodiment of the present application is as follows. Figure 7 As shown, the above step 42 may include the following steps:
[0177] Step 71: perform correlation calculation based on the target constant and the preset constant of the log to be processed to obtain a correlation value.
[0178] In this step, the target constant of the log to be processed is compared with the preset constant, that is, the prefix part of each sub-log of the log to be processed is compared with the preset constant to perform similarity calculation to obtain a similarity value.
[0179] Optionally, the similarity between each preset constant and the target constant is calculated.
[0180] In a possible implementation, by matching the prefix part of each sub-log of the log to be processed with each prefix in the preset constant, the ratio of the number of identical prefixes to the total number of prefixes in the preset constant is a relevant value.
[0181] In addition, in order to reduce the amount of calculation, after the target constant to be matched and the preset constant are intersected and duplicated, the number of remaining sub-logs must be greater than half the length of the target constant.
[0182] Part of the code for this step is as follows:
[0183]
[0184] Step 72: If the correlation value is greater than a preset correlation threshold, the log type corresponding to the preset constant is determined as the second log type of the log to be processed.
[0185] In this step, the preset constants corresponding to all templates are traversed, and if the correlation is greater than the preset correlation threshold, it is considered that the match is successful, that is, the log type corresponding to the preset constant is considered to be the second log type of the log to be processed.
[0186] Step 73: If the correlation value is less than or equal to the preset correlation threshold, the target constant corresponding to the log to be processed is used as a new preset constant, and a new log type is established according to the new preset constant, and the new log type is determined as the second log type of the log to be processed.
[0187] In this step, if the correlation value is less than or equal to the preset correlation threshold, it means that the preset constant has a low similarity with the target constant, and a new preset constant can be re-determined.
[0188] Optionally, the target constant corresponding to the log to be processed is used as a new preset constant, in which a new log type is determined, and the new log type is used as the second log type of the log to be processed, and an identifier of the log to be processed is added under the new log type.
[0189] The log processing method provided by the embodiment of the present application calculates the correlation according to the target constant and the preset constant of the log to be processed to obtain the correlation value. When the correlation value is greater than the preset correlation threshold, the log type corresponding to the preset constant is determined as the second log type of the log to be processed. When the correlation value is less than or equal to the preset correlation threshold, the target constant corresponding to the log to be processed is used as a new preset constant, and a new log type is established according to the new preset constant, and the new log type is determined as the second log type of the log to be processed. The technical solution realizes the second log type of the log to be processed by presetting the correlation threshold.
[0190] Based on the above method embodiment, Figure 8 This is a schematic diagram of the structure of the log processing device provided in the embodiment of the present application. Figure 8 As shown, the log processing device includes: an acquisition module 81, a determination module 82, and a storage module 83;
[0191] The acquisition module 81 is used to acquire the pending logs of the application program, where the pending logs are the logs after regular optimization;
[0192] A determination module 82 is used to perform segmentation processing on the log to be processed to obtain at least two sub-logs, and determine the number of sub-logs as the length of the log to be processed, wherein the segmentation processing includes any one of the following: segmentation by space, segmentation by comma, and segmentation by line break, and according to the length of the log to be processed and at least two sub-logs, determine the first log type of the log to be processed in a preset type model tree, wherein the root node of the type model tree includes multiple internal nodes, each of the internal nodes includes multiple prefix trees, and the length of the log to be processed that can be stored under each internal node is different. The leaf nodes under the multiple prefix trees under each internal node store log identifiers of different log types and corresponding log templates, and the prefix tree includes N layers of child nodes, and the N layers of child nodes correspond to prefixes from the first sub-log to the Nth sub-log in sequence, respectively, and the value of N is less than or equal to the number of sub-logs, and the leaf node is the child node of the last layer of the prefix tree;
[0193] The storage module 83 is used to store the identifier of the log to be processed in the storage space under the leaf node for storing the first log type.
[0194] In a possible design of the embodiment of the present application, the determination module 82 is further used to:
[0195] Combine the prefix part of each sub-log in at least two sub-logs according to the segmentation order to obtain the target constant of the log to be processed;
[0196] Determine a second log type of the log to be processed according to a target constant of the log to be processed and a correspondence between a preset constant and the log type;
[0197] The identifier of the log to be processed is stored in the storage space corresponding to the second log type.
[0198] In this possible design, the determination module 82 is further used to:
[0199] A mapping relationship between the first log type and the second log type of the log to be processed is established.
[0200] In another possible design of the embodiment of the present application, the determination module 82 determines the first log type of the log to be processed in a preset type model tree according to the length of the log to be processed and at least two sub-logs, and is specifically used to:
[0201] According to the length of the log to be processed, determine the target internal node corresponding to the log to be processed from multiple internal nodes;
[0202] According to the multiple sub-logs, determine the target leaf node corresponding to the log to be processed in the multiple prefix trees under the target internal node;
[0203] According to the log type corresponding to the target leaf node, the first log type of the log to be processed is determined.
[0204] In this possible design, the determination module 82 is further used to:
[0205] According to the multiple sub-logs, if the target leaf node corresponding to the log to be processed is not determined in the multiple prefix trees under the target internal node, a new leaf node is established under the target internal node as the target leaf node;
[0206] Create a new log type under a new leaf node corresponding to the target internal node;
[0207] The new log type under the new leaf node is determined as the first log type of the log to be processed.
[0208] Optionally, the determination module 82 is further configured to:
[0209] Calculate similarity between the multiple sub-logs and the log template stored under the target leaf node to obtain at least one log template whose similarity value is greater than a preset similarity threshold;
[0210] The identifier of the log to be processed is stored under the log template corresponding to the largest similarity value among the at least one similarity value.
[0211] Optionally, the determining module 82 is further configured to:
[0212] Performing similarity calculations on the multiple sub-logs and the log templates stored under the target leaf node, and failing to obtain at least one log template having a similarity value greater than a preset similarity threshold;
[0213] Generate a new log template according to the sub-nodes of each layer in the prefix tree corresponding to the target leaf node and the target internal node;
[0214] The identifier of the log to be processed is stored under the new log template.
[0215] In another possible design of the embodiment of the present application, the determination module 82 determines the second log type of the log to be processed according to the target constant of the log to be processed and the correspondence between the preset constant and the log type, specifically for:
[0216] Perform correlation calculation based on the target constant and the preset constant of the log to be processed to obtain a correlation value;
[0217] If the correlation value is greater than a preset correlation threshold, the log type corresponding to the preset constant is determined as the second log type of the log to be processed.
[0218] In this possible design, the determination module 82 is further specifically configured to:
[0219] If the correlation value is less than or equal to the preset correlation threshold, the target constant corresponding to the log to be processed is used as a new preset constant;
[0220] A new log type is established according to the new preset constant, and the new log type is determined as the second log type of the log to be processed.
[0221] The log processing device provided in the embodiment of the present application can be used to execute the technical solution corresponding to the log processing method in the above embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0222] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software calling through processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. In addition, all or part of these modules can be integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
[0223] Fig. 9 This is a schematic diagram of the structure of the server provided in the embodiment of the present application. Fig. 9 As shown, the server may include: a processor 90 , a memory 91 , and computer program instructions stored in the memory 91 and executable on the processor 90 .
[0224] The processor 90 executes the computer execution instructions stored in the memory 91, so that the processor 90 executes the scheme in the above embodiment. The processor 90 can be a general-purpose processor, including a central processing unit CPU, a network processor (NP), etc.; it can also be a digital signal processor DSP, an application-specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0225] Optionally, the server may further include: a transceiver 92 .
[0226] The memory 91 and the transceiver 92 are connected to the processor 90 via a system bus and communicate with each other. The memory 91 is used to store computer program instructions.
[0227] The transceiver 92 is used to communicate with other devices, and the transceiver 92 constitutes a communication interface.
[0228] Optionally, in hardware implementation, the above Figure 8 The acquisition module 81 in the illustrated embodiment corresponds to the transceiver 92 in this embodiment.
[0229] The system bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0230] The server provided in the embodiment of the present application can be used to execute the technical solution corresponding to the log processing method in the above embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0231] An embodiment of the present application also provides a chip for running instructions, which is used to execute the technical solution of the log processing method in the above embodiment.
[0232] An embodiment of the present application further provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed on a computer device, the computer device executes the technical solution of the log processing method in the above embodiment.
[0233] An embodiment of the present application further provides a computer program product, including a computer program, which is used to execute the technical solution of the log processing method in the above embodiment when executed by a processor.
[0234] The computer-readable storage medium mentioned above can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special computer device.
[0235] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A log processing method, characterized in that: include: Obtaining the pending log of the application, wherein the pending log is a log after regular optimization; The log to be processed is split into at least two sub-logs, and the number of sub-logs is determined as the length of the log to be processed, wherein the splitting process includes any one of the following: splitting by space, splitting by comma, and splitting by line break; According to the length of the log to be processed and the at least two sub-logs, a first log type of the log to be processed is determined in a preset type model tree, the root node of the type model tree includes multiple internal nodes, each internal node includes multiple prefix trees, the length of the log to be processed that can be stored under each internal node is different, and the leaf nodes under the multiple prefix trees under each internal node store log identifiers of different log types and corresponding log templates, the prefix tree includes N layers of child nodes, the N layers of child nodes correspond to prefixes from the first sub-log to the Nth sub-log in sequence, the value of N is less than or equal to the number of the sub-logs, and the leaf node is the child node of the last layer of the prefix tree; Storing the identifier of the log to be processed in a storage space under a leaf node for storing the first log type; The method further comprises: Combining the prefix part of each sub-log in the at least two sub-logs according to the segmentation order to obtain the target constant of the log to be processed; Determining a second log type of the log to be processed according to a target constant of the log to be processed and a correspondence between a preset constant and a log type; The identifier of the log to be processed is stored in the storage space corresponding to the second log type.
2. The method according to claim 1, characterized in that The method further comprises: A mapping relationship between the first log type and the second log type of the log to be processed is established.
3. The method according to claim 1 or 2, characterized in that: The step of determining the first log type of the log to be processed in a preset type model tree according to the length of the log to be processed and the at least two sub-logs includes: According to the length of the log to be processed, determining a target internal node corresponding to the log to be processed among the multiple internal nodes; According to the multiple sub-logs, determining a target leaf node corresponding to the log to be processed in multiple prefix trees under the target internal node; According to the log type corresponding to the target leaf node, a first log type of the log to be processed is determined.
4. The method according to claim 3, characterized in that After determining the target internal node corresponding to the log to be processed among the multiple internal nodes according to the length of the log to be processed, the method further includes: According to the multiple sub-logs, if a target leaf node corresponding to the log to be processed is not determined in the multiple prefix trees under the target internal node, a new leaf node is established under the target internal node as the target leaf node; Establishing a new log type under the new leaf node corresponding to the target internal node; The new log type under the new leaf node is determined as the first log type of the log to be processed.
5. The method according to claim 3, characterized in that: After determining the first log type of the log to be processed according to the log type corresponding to the target leaf node, the method further includes: Calculate similarity between the multiple sub-logs and the log template stored under the target leaf node to obtain at least one log template whose similarity value is greater than a preset similarity threshold; The identifier of the log to be processed is stored under the log template corresponding to the largest similarity value among the at least one similarity value.
6. The method according to claim 5, characterized in that The method further comprises: Performing similarity calculations on the multiple sub-logs and the log templates stored under the target leaf node, and failing to obtain at least one log template having a similarity value greater than a preset similarity threshold; Generate a new log template according to the sub-nodes of each layer in the prefix tree corresponding to the target leaf node and the target internal node; The identifier of the log to be processed is stored under the new log template.
7. The method according to claim 2, characterized in that The determining the second log type of the log to be processed according to the target constant of the log to be processed and the corresponding relationship between the preset constant and the log type includes: Performing correlation calculation based on the target constant of the log to be processed and the preset constant to obtain a correlation value; If the correlation value is greater than a preset correlation threshold, the log type corresponding to the preset constant is determined as the second log type of the log to be processed.
8. The method according to claim 7, characterized in that After performing correlation calculation according to the target constant of the log to be processed and the preset constant to obtain a correlation value, the method further includes: If the correlation value is less than or equal to the preset correlation threshold, the target constant corresponding to the log to be processed is used as a new preset constant; A new log type is established according to the new preset constant, and the new log type is determined as the second log type of the log to be processed.
9. A log processing device, characterized in that: include: Acquisition module, determination module, storage module; The acquisition module is used to acquire the pending log of the application, wherein the pending log is a log after regular optimization; The determination module is used to split the log to be processed to obtain at least two sub-logs, and determine the number of sub-logs as the length of the log to be processed, the splitting process includes any one of the following: splitting by space, splitting by comma, and splitting by line break, and according to the length of the log to be processed and the at least two sub-logs, determine the first log type of the log to be processed in a preset type model tree, the root node of the type model tree includes multiple internal nodes, each internal node includes multiple prefix trees, the length of the log to be processed that can be stored under each internal node is different, and the leaf nodes under the multiple prefix trees under each internal node store log identifiers of different log types and corresponding log templates, the prefix tree includes N layers of child nodes, the N layers of child nodes correspond to prefixes from the first sub-log to the Nth sub-log in sequence, the value of N is less than or equal to the number of sub-logs, and the leaf node is the child node of the last layer of the prefix tree; The storage module is used to store the identifier of the log to be processed in the storage space under the leaf node for storing the first log type; The determination module is further used to: combine the prefix part of each sub-log in at least two sub-logs according to the segmentation order to obtain a target constant of the log to be processed; determine the second log type of the log to be processed according to the target constant of the log to be processed and the corresponding relationship between the preset constant and the log type; The identifier of the log to be processed is stored in the storage space corresponding to the second log type.
10. A server, comprising: A processor, a memory, and computer program instructions stored in the memory and executable on the processor, wherein the processor implements the log processing method as described in any one of claims 1 to 8 when executing the computer program instructions.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the log processing method as described in any one of claims 1 to 8 above.
12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, it is used to implement the log processing method as described in any one of claims 1 to 8 above.
Citation Information
Patent Citations
Log compression method and device, electronic equipment and storage medium
CN112559465A
