Log processing method and device
By constructing log templates and extracting key information, the problems of resource waste and information interference in log analysis are solved, and the accuracy and efficiency of analysis are improved.
Patent Information
- Application Number
- CN201910914657.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-09-26
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2039-09-26
Smart Images

Figure CN112559474B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing, and in particular to a log processing method and device. Background Art
[0002] In the log analysis platform, it is necessary to collect, store and analyze different logs of various systems. Among them, logs include system logs, webserver logs, error logs, application logs, etc. The analysis and processing of logs mainly involves filtering, labeling, statistics and other operations in the form of text processing. The current method is to perform text processing such as word segmentation and word vectorization on each log, and then perform model training and analysis.
[0003] There are some defects in the current method. For example, the analysis of all the text in the log consumes a lot of resources. In addition, the model learning and analysis process will be disturbed by the information in the log that has little relevance to the analysis requirements, which affects the accuracy of model learning and analysis. Summary of the invention
[0004] A technical problem to be solved by the present disclosure is to provide a log processing method and device, which can improve the accuracy of log analysis.
[0005] According to one aspect of the present disclosure, a log processing method is proposed, including: performing word segmentation processing on a sample log file using a stop word library to obtain multiple words in the sample log file; performing word frequency statistics on the multiple words, and taking words with a word frequency greater than a word frequency threshold as high-frequency words; taking a predetermined number of high-frequency words that appear continuously in the sample log file as high-frequency phrases; calculating the weighted probability of each high-frequency phrase and punctuation combination; constructing a log template based on the high-frequency phrase and punctuation combination whose weighted probability is greater than the probability threshold; and extracting key information in the log data based on the log template.
[0006] In some embodiments, the correlation between words in each high-frequency phrase is verified; and the weighted probability of the high-frequency phrase and punctuation combination consisting of the correlated phrases is calculated.
[0007] In some embodiments, calculating the weighted probability of a high-frequency phrase and punctuation combination consisting of related phrases includes: counting the probability of punctuation appearing before and after the high-frequency phrase consisting of related phrases; determining the weight of the corresponding punctuation; and taking the product of the probability of punctuation appearing and the weight of the corresponding punctuation as the weighted probability of the high-frequency phrase and punctuation combination consisting of related phrases.
[0008] In some embodiments, verifying the correlation between words in each high-frequency word group includes: performing a chi-square test on the words in each high-frequency word group to determine the correlation between words in each high-frequency word group.
[0009] In some embodiments, treating a predetermined number of high-frequency words that appear consecutively as a high-frequency phrase includes: treating a predetermined number of high-frequency words as a combination, and counting the frequency of occurrence of the combination in a sample log file; treating a combination whose occurrence frequency is greater than a frequency threshold as a high-frequency phrase.
[0010] In some embodiments, punctuation characters and spaces are not included in the stop word library.
[0011] According to another aspect of the present disclosure, a log processing device is also proposed, including: a word segmentation processing unit, configured to use a stop word library to perform word segmentation processing on a sample log file to obtain multiple words in the sample log file; a high-frequency word determination unit, configured to perform word frequency statistics on multiple words, and regard words with a word frequency greater than a word frequency threshold as high-frequency words; a high-frequency phrase determination unit, configured to regard a predetermined number of high-frequency words that appear continuously in the sample log file as high-frequency phrases; a weighted probability determination unit, configured to calculate the weighted probability of each high-frequency phrase and punctuation combination; a log template construction unit, configured to construct a log template based on the high-frequency phrase and punctuation combination whose weighted probability is greater than the probability threshold; a key information extraction unit, configured to extract key information in the log data based on the log template.
[0012] In some embodiments, the relevance verification unit is configured to verify the relevance between words in each high-frequency phrase; wherein the weighted probability determination unit is configured to calculate the weighted probability of the high-frequency phrase and punctuation combination consisting of the relevance phrase.
[0013] According to another aspect of the present disclosure, a log processing device is further provided, comprising: a memory; and a processor coupled to the memory, wherein the processor is configured to execute the log processing method as described above based on instructions stored in the memory.
[0014] According to another aspect of the present disclosure, a computer-readable storage medium is further provided, on which computer program instructions are stored, and when the instructions are executed by a processor, the above-mentioned log processing method is implemented.
[0015] Compared with the related art, the present invention discovers the log template hidden in the log and uses the log template to extract the key information in the log related to the analysis requirements, thereby eliminating the interference of other text information in the subsequent processing process and improving the accuracy of log analysis. In addition, in the subsequent model learning and analysis process, only the key information in the log is analyzed and processed, which also saves analysis time and resources and improves system efficiency.
[0016] Other features and advantages of the present disclosure will become apparent from the following detailed description of exemplary embodiments of the present disclosure with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings, which constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0018] The present disclosure may be more clearly understood from the following detailed description with reference to the accompanying drawings, in which:
[0019] Figure 1 The following is a flowchart of some embodiments of the log processing method disclosed herein.
[0020] Figure 2 Schematic diagram of the flow of other embodiments of the log processing method disclosed in the present invention.
[0021] Figure 3 The following is a schematic diagram of the structure of some embodiments of the log processing device disclosed in the present invention.
[0022] Figure 4 Schematic diagram of the structure of some other embodiments of the log processing device disclosed in the present invention.
[0023] Figure 5 Schematic diagram of the structure of some other embodiments of the log processing device disclosed in the present invention.
[0024] Figure 6 Schematic diagram of the structure of some other embodiments of the log processing device disclosed in the present invention. DETAILED DESCRIPTION
[0025] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present disclosure unless otherwise specifically stated.
[0026] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.
[0027] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present disclosure, its application, or uses.
[0028] Technologies, methods, and apparatus known to ordinary technicians in the relevant field may not be discussed in detail, but where appropriate, such technologies, methods, and apparatus should be considered part of the authorization specification.
[0029] In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not as limiting. Therefore, other examples of the exemplary embodiments may have different values.
[0030] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0031] In order to make the objectives, technical solutions and advantages of the present disclosure more clearly understood, the present disclosure is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.
[0032] Figure 1 The following is a flowchart of some embodiments of the log processing method disclosed herein.
[0033] In step 110, the sample log file is segmented using a stop word library to obtain a plurality of words in the sample log file.
[0034] The words in the stop word library are words that appear frequently but are irrelevant to the template information. The stop word library includes, for example, general stop words and special stop words involved in the system, but the stop word library does not contain punctuation marks and spaces.
[0035] In step 120, a frequency count is performed on a plurality of words, and words with a frequency greater than a frequency threshold are regarded as high-frequency words. The frequency count process does not include the count of punctuation marks, spaces, and other characters.
[0036] In some embodiments, the word frequency statistics of the sample log file after word segmentation can be performed according to the number of times or percentage of word occurrence, and the words can be sorted in order of frequency from large to small, and the words with a frequency greater than the word frequency threshold are selected as high-frequency words.
[0037] In step 130, a predetermined number of high-frequency words that appear continuously in the sample log file are taken as high-frequency word groups.
[0038] For example, a predetermined number of high-frequency words are taken as a combination, and the frequency of occurrence of the combination in the sample log file is counted; and a combination with an occurrence frequency greater than a frequency threshold is taken as a high-frequency phrase.
[0039] In step 140, the weighted probability of each high-frequency word group and punctuation combination is calculated.
[0040] Since log templates often appear in the form of a combination of phrases and punctuation marks, we can first count the probability of punctuation marks appearing before and after the high-frequency phrases, and then determine the weight of the corresponding punctuation marks. For example, the weight of [] is 2, the weight of : is 1, the weight of a space is 0.8, and the weight of no punctuation marks is 0.2, etc. The higher the frequency of punctuation marks in log templates, the greater the weight. The product of the probability of punctuation marks appearing and the weight of the corresponding punctuation marks is taken as the weighted probability.
[0041] In step 150, a log template is constructed based on high-frequency phrases and punctuation combinations whose weighted probabilities are greater than a probability threshold.
[0042] For example, the weighted probabilities are arranged from large to small, and the top N high-frequency phrases and punctuation combinations are selected to construct a log template.
[0043] In step 160, key information in the log data is extracted according to the log template. In the subsequent model learning or analysis process, only the key information in the log can be analyzed and processed.
[0044] In this embodiment, by discovering the log template hidden in the log and using the log template to extract key information in the log related to the analysis requirements, interference from other text information is eliminated in the subsequent processing process, thereby improving the accuracy of log analysis.
[0045] Figure 2 Schematic diagram of the flow of other embodiments of the log processing method disclosed in the present invention.
[0046] In step 210, the sample log file is segmented using the stop word library to obtain a plurality of words in the sample log file. In order to execute step 250, in this step, the stop word library does not include punctuation marks and spaces.
[0047] In step 220, a frequency count is performed on a plurality of words, and words with a frequency greater than a frequency threshold are regarded as high-frequency words. For example, words with a frequency greater than 30% are regarded as high-frequency words.
[0048] In step 230, a predetermined number of high-frequency words are taken as a combination, and the frequency of occurrence of the combination in the sample log file is counted. The combination with an occurrence frequency greater than a frequency threshold is taken as a high-frequency word group.
[0049] For example, high-frequency words are combined in pairs, and the frequency of the combination in the same sample log file is counted; then three high-frequency words are taken as a combination, and the frequency of the combination in the same sample log file is counted; a combination with a frequency greater than 15% is marked as a high-frequency phrase.
[0050] In step 240, the correlation between the words in each high-frequency phrase is verified.
[0051] For two or three words that appear simultaneously at a high frequency above a certain threshold, since each word itself is a high-frequency word, it is impossible to determine whether these two or three words are a fixed phrase or the result of a large number of random occurrences. Therefore, it is necessary to verify the correlation between the words.
[0052] In some embodiments, the words in each high-frequency phrase are subjected to chi-square validation to determine the correlation between the words in each high-frequency phrase. For example, two words in a high-frequency phrase are taken as independent variables, and the chi-square value between the two variables is calculated. When the chi-square value is greater than 3.84, the two words are considered to be correlated. For example, "login" and "time" in the high-frequency phrase "login time" are correlated; "error" and "code" in the high-frequency phrase "error code" are correlated.
[0053] In some embodiments, the words in each high-frequency word group are word-vectorized, and then the distance between the word vectors is calculated to determine the correlation between the words in each high-frequency word group.
[0054] In step 250, weighted probabilities of high-frequency phrases and punctuation combinations consisting of associated phrases are calculated.
[0055] For example, high-frequency phrases are scanned, the probability of punctuation marks appearing before and after the high-frequency phrases is counted, and then multiplied by the weight of the corresponding punctuation marks to obtain weighted probabilities. For example, the weighted probability of "login time" is 0.3, the weighted probability of "error code" is 0.4, and so on.
[0056] In step 260, a log template is constructed based on the high-frequency phrases and punctuation combinations with weighted probabilities greater than the probability threshold. For example, three groups of high-frequency phrases and punctuation combinations with the largest weighted probabilities are selected to obtain a log template.
[0057] In step 270, key information in the log data is extracted according to the log template.
[0058] In step 280, model learning and analysis are performed based on key information in the log data.
[0059] In this embodiment, by discovering the log template hidden in the log and using the log template to extract key information in the log related to the analysis needs, model learning and analysis are performed based on the key information in the log data, which saves analysis time and resources and improves system efficiency.
[0060] Figure 3 The log processing device of the present disclosure is a schematic diagram of the structure of some embodiments of the log processing device. The log processing device includes: a word segmentation processing unit 310, a high-frequency word determination unit 320, a high-frequency phrase determination unit 330, a weighted probability determination unit 340, a log template construction unit 350 and a key information extraction unit 360.
[0061] The word segmentation processing unit 310 is configured to perform word segmentation processing on the sample log file using a stop word library to obtain a plurality of words in the sample log file.
[0062] The high-frequency word determination unit 320 is configured to perform word frequency statistics on a plurality of words, and regard words whose word frequencies are greater than a word frequency threshold as high-frequency words.
[0063] The high-frequency phrase determination unit 330 is configured to take a predetermined number of high-frequency words that appear continuously in the sample log file as high-frequency phrases.
[0064] For example, a predetermined number of high-frequency words are taken as a combination, and the frequency of occurrence of the combination in the sample log file is counted; and a combination with an occurrence frequency greater than a frequency threshold is taken as a high-frequency phrase.
[0065] The weighted probability determination unit 340 is configured to calculate the weighted probability of each high-frequency phrase and punctuation combination.
[0066] For example, the probability of punctuation marks appearing before and after high-frequency phrases is counted; the weights of the corresponding punctuation marks are determined; and the product of the probability of punctuation marks appearing and the weights of the corresponding punctuation marks is used as the weighted probability.
[0067] The log template construction unit 350 is configured to construct a log template according to the high-frequency phrase and punctuation combination whose weighted probability is greater than the probability threshold.
[0068] The key information extraction unit 360 is configured to extract key information from the log data according to the log template.
[0069] In this embodiment, by discovering the log template hidden in the log and using the log template to extract key information in the log related to the analysis requirements, interference from other text information is eliminated in the subsequent processing process, thereby improving the accuracy of data processing.
[0070] In other embodiments of the present disclosure, Figure 4 As shown, the log processing device also includes a relevance verification unit 410, which is configured to verify the relevance between words in each high-frequency phrase; wherein the weighted probability determination unit 340 is configured to calculate the weighted probability of the high-frequency phrase and punctuation combination consisting of the related phrases.
[0071] For two or three words that appear simultaneously at a high frequency above a certain threshold, since each word itself is a high-frequency word, it is impossible to determine whether these two or three words are a fixed phrase or the result of a large number of random occurrences. Therefore, it is necessary to verify the correlation between the words.
[0072] In some embodiments, the words in each high-frequency phrase are subjected to chi-square validation to determine the correlation between the words in each high-frequency phrase. For example, two words in a high-frequency phrase are taken as independent variables, and the chi-square value between the two variables is calculated. When the chi-square value is greater than 3.84, the two words are considered to be correlated. For example, "login" and "time" in the high-frequency phrase "login time" are correlated; "error" and "code" in the high-frequency phrase "error code" are correlated.
[0073] Figure 5 Schematic diagram of the structure of some other embodiments of the log processing device disclosed in the present invention. The log processing device includes: a memory 510 and a processor 520, wherein:
[0074] The memory 510 can be a disk, a flash memory, or any other non-volatile storage medium. The memory is used to store Figure 1 , 2 The processor 520 is coupled to the memory 510 and can be implemented as one or more integrated circuits, such as a microprocessor or a microcontroller. The processor 520 is used to execute the instructions stored in the memory.
[0075] In some embodiments, it is also possible to Figure 6 As shown, the log processing device 600 includes a memory 610 and a processor 620. The processor 620 is coupled to the memory 610 via a BUS 630. The log processing device 600 can also be connected to an external storage device 660 via a storage interface 640 to call external data, and can also be connected to a network or another computer system (not shown) via a network interface 660, which will not be described in detail here.
[0076] In this embodiment, the data instructions are stored in the memory, and then the instructions are processed by the processor, thereby improving the accuracy of data processing.
[0077] In some other embodiments, a computer readable storage medium stores computer program instructions, which when executed by a processor implement Figure 1 , 2 The steps of the method in the corresponding embodiment. Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, devices, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable non-transient storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0078] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram and the combination of processes and / or blocks in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0079] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0080] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0081] So far, the present disclosure has been described in detail. In order to avoid obscuring the concept of the present disclosure, some details known in the art are not described. Based on the above description, those skilled in the art can fully understand how to implement the technical solution disclosed here.
[0082] Although some specific embodiments of the present disclosure have been described in detail by way of example, it should be understood by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present disclosure. It should be understood by those skilled in the art that the above embodiments may be modified without departing from the scope and spirit of the present disclosure. The scope of the present disclosure is defined by the appended claims.
Claims
1. A log processing method, include: Perform word segmentation processing on the sample log file using a stop word library to obtain multiple words in the sample log file; Performing word frequency statistics on the multiple words, and taking words whose word frequencies are greater than a word frequency threshold as high-frequency words; A predetermined number of high-frequency words that appear continuously in the sample log file are regarded as high-frequency phrases; Calculating the weighted probability of each high-frequency phrase and punctuation combination; Construct a log template based on high-frequency phrases and punctuation combinations whose weighted probabilities are greater than a probability threshold; According to the log template, key information in the log data is extracted.
2. The log processing method according to claim 1, further comprising: include: Verifying the correlation between words in each of the high-frequency phrases; Calculate the weighted probabilities of high-frequency phrases and punctuation combinations consisting of related phrases.
3. The log processing method according to claim 2, in, Calculating the weighted probability of high-frequency phrases and punctuation combinations consisting of related phrases includes: Counting the probability of punctuation marks appearing before and after the high-frequency phrases formed by the related phrases; Determine the weight of the corresponding punctuation point; The product of the probability of occurrence of the punctuation mark and the weight of the corresponding punctuation mark is used as the weighted probability of the combination of the high-frequency phrase and the punctuation mark formed by the associated phrase.
4. The log processing method according to claim 2, in, Verifying the correlation between words in each of the high-frequency phrases includes: The words in each of the high-frequency phrases are subjected to a chi-square test to determine the correlation between the words in each of the high-frequency phrases.
5. The log processing method according to claim 1, in, The high-frequency words that appear continuously for a predetermined number of times are included as high-frequency phrases: Taking a predetermined number of high-frequency words as a combination, and counting the frequency of occurrence of the combination in the sample log file; The combinations with a frequency greater than the frequency threshold are regarded as high-frequency phrases.
6. The log processing method according to any one of claims 1 to 5, in, The stop word library does not include punctuation marks and spaces.
7. A log processing device, include: A word segmentation processing unit is configured to perform word segmentation processing on the sample log file using a stop word library to obtain a plurality of words in the sample log file; A high-frequency word determination unit is configured to perform word frequency statistics on the multiple words, and regard the words whose word frequency is greater than the word frequency threshold as high-frequency words; a high-frequency phrase determination unit, configured to take a predetermined number of high-frequency words that appear continuously in the sample log file as a high-frequency phrase; A weighted probability determination unit, configured to calculate the weighted probability of each of the high-frequency phrases and punctuation combinations; a log template construction unit configured to construct a log template according to a high-frequency phrase and punctuation combination whose weighted probability is greater than a probability threshold; The key information extraction unit is configured to extract key information from the log data according to the log template.
8. The log processing device according to claim 7, further comprising: include: A relevance verification unit, configured to verify the relevance between words in each of the high-frequency phrases; The weighted probability determination unit is configured to calculate the weighted probability of the combination of high-frequency phrases and punctuation marks consisting of the associated phrases.
9. A log processing device, include: Memory; as well as A processor coupled to the memory, wherein the processor is configured to execute the log processing method according to any one of claims 1 to 6 based on instructions stored in the memory.
10. A computer-readable storage medium having computer program instructions stored thereon, wherein the instructions, when executed by a processor, implement the log processing method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Method for ordering significance of keywords in text
CN103744951A
Log based computer system fault diagnosis method and device
CN103761173A
SRC calculation method
CN104317783A
Method for extracting Chinese institutional unit name from text information
CN105045847A
Method and apparatus for creating switch log template
CN106055452A
