Abnormal log detection method, system and device, storage medium and product
By converting log word segmentation into numerical sequences and dividing them into clusters, combined with user annotations, abnormal log detection without prior knowledge is achieved, solving the problems of complex detection and low efficiency in the existing technology, and improving detection efficiency and accuracy.
Patent Information
- Application Number
- CN202410875636.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-10-29
AI Technical Summary
Existing technologies require a large amount of data and prior knowledge in abnormal log detection, resulting in complex detection and low efficiency.
By dividing the logs to be detected into log word segments and converting them into numerical sequences, and using similarity to divide clusters, users mark abnormal clusters to automatically identify abnormal logs, avoiding reliance on prior knowledge.
It realizes the simple and efficient detection of abnormal logs without prior knowledge, and improves the detection efficiency and accuracy.
Smart Images

Figure CN118861284A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of log monitoring technology, and in particular to abnormal log detection methods, systems, devices, storage media and products. Background Art
[0002] Exception logs are log records generated when software or systems encounter abnormal conditions or errors during operation. Typically, exception logs contain detailed information about the error, which can help developers or system administrators diagnose and solve the problem.
[0003] Since the number of logs generated by software or systems during operation is large, and the logs include normal operation logs and abnormal logs, in order to accurately identify these abnormal logs, they are usually screened through anomaly detection algorithm models. However, the construction of anomaly detection algorithm models is not easy. Anomaly detection algorithm models not only require huge data resources as a cornerstone to ensure the accuracy and stability of the model, but also rely on rich prior knowledge to guide the design and tuning of the model.
[0004] Therefore, how to propose a simple method for detecting abnormal logs is a technical problem that needs to be solved by those skilled in the art.
[0005] The above contents are only used to assist in understanding the technical solutions of the embodiments of the present application, and do not constitute an admission that the above contents are prior art. Summary of the invention
[0006] The main purpose of the embodiments of the present application is to provide an abnormal log detection method, system, device, storage medium and product, aiming to solve the technical problem of how to propose a simple abnormal log detection method.
[0007] To achieve the above objectives, the present application provides an abnormal log detection method, the method comprising:
[0008] Divide each log to be detected into log words, and convert each log word into numbers to obtain a digital sequence corresponding to each log to be detected;
[0009] Dividing each of the digital sequences into clusters, wherein the similarity between the non-cluster center digital sequences and the digital sequences corresponding to the cluster center in the same cluster is greater than or equal to a preset similarity threshold, and the same digital sequence does not exist in multiple clusters;
[0010] The cluster corresponding to the log marked abnormal by the user in each of the logs to be detected is taken as an abnormal cluster, and the log to be detected corresponding to each of the digital sequences in the abnormal cluster is taken as an abnormal log.
[0011] In one embodiment, the step of calculating the similarity between the non-cluster center digital sequence and the digital sequence corresponding to the cluster center in the same cluster includes:
[0012] Determine a first number of the number sequence corresponding to the cluster center, a second number of the number sequence of non-cluster centers, and a third number of the same numbers in the number sequence of the cluster center and the number sequence of non-cluster centers;
[0013] The sum of the first number of digits and the second number of digits is calculated, and the ratio of the third number of digits to the sum is used as the similarity between the non-cluster center digit sequence and the cluster center digit sequence.
[0014] In one embodiment, after the step of dividing each of the digital sequences into clusters, the method further includes:
[0015] After obtaining the target log, the target log is divided into target log words, and each target log word is converted into a number to obtain a target number sequence, wherein the target log refers to a newly received log that has not been divided into clusters;
[0016] Determine the similarities between the target digital sequence and the cluster centers of the clusters, and determine the maximum similarity among the similarities;
[0017] If it is detected that the maximum similarity is greater than or equal to the preset similarity threshold, the cluster center corresponding to the maximum similarity is used as the target cluster center, and the target digital sequence is divided into the cluster corresponding to the target cluster center.
[0018] In one embodiment, the step of converting each of the log segment words into numbers to obtain a number sequence corresponding to the log to be detected includes:
[0019] The word frequencies corresponding to the log segmentations are calculated, and according to the order of the log segmentations in the log to be detected, the word frequencies corresponding to the log segmentations are combined into a digital sequence corresponding to the log to be detected.
[0020] In one embodiment, the step of converting each of the log segment words into numbers to obtain a number sequence corresponding to the log to be detected includes:
[0021] Map each of the log word segments to the same vector space to obtain a real number vector corresponding to each of the log word segments; and according to the order of each of the log word segments in the log to be detected, organize the real number vectors corresponding to each of the log word segments into a digital sequence corresponding to each of the logs to be detected.
[0022] In one embodiment, before the step of dividing each of the digital sequences into clusters, the method further includes:
[0023] Counting the number of numbers contained in each of the digital sequences respectively, and determining the maximum number among the numbers;
[0024] Use preset numbers to fill in the number sequences in which the number of numbers in each of the number sequences is less than the maximum number, so that the number of numbers in each of the number sequences after filling reaches the maximum number.
[0025] The present application also provides an abnormal log detection system, the system comprising:
[0026] A character conversion module is used to divide each log to be detected into log words, and convert each log word into a number to obtain a digital sequence corresponding to each log to be detected;
[0027] A log classification module, used for dividing each of the digital sequences into clusters, wherein the similarity between the non-cluster center digital sequences and the digital sequences corresponding to the cluster center in the same cluster is greater than or equal to a preset similarity threshold, and the same digital sequence does not exist in multiple clusters;
[0028] The detection module is used to take the cluster corresponding to the log marked abnormal by the user in each of the logs to be detected as an abnormal cluster, and take the log to be detected corresponding to each digital sequence in the abnormal cluster as an abnormal log.
[0029] An embodiment of the present application further proposes an abnormal log detection device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the abnormal log detection method described above.
[0030] The embodiment of the present application further proposes a storage medium, which is a computer-readable storage medium. A computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the abnormal log detection method as described above are implemented.
[0031] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of the abnormal log detection method described above are implemented.
[0032] One or more technical solutions proposed in the embodiments of the present application have at least the following technical effects:
[0033] The embodiment of the present application divides each log to be detected into each log segmentation, and converts each log segmentation into a number, so as to obtain a digital sequence corresponding to each log to be detected, and can convert the log to be detected into a digital sequence for computer recognition; then divide each digital sequence into each cluster, wherein the similarity between the non-cluster center digital sequence and the digital sequence corresponding to the cluster center in the same cluster is greater than or equal to the preset similarity threshold, and the same digital sequence does not exist in multiple clusters, and can divide the digital sequences with high similarity into the same cluster without prior knowledge, that is, divide the logs to be detected with high similarity into the same cluster; then the cluster corresponding to the log selected by the user in each log to be detected is used as an abnormal cluster, and the log to be detected corresponding to the digital sequence in the abnormal cluster is used as an abnormal log, and the log to be detected with high similarity to the log selected by the user can be automatically identified as an abnormal log under the premise that the user selects an abnormal log in the log to be detected. Thus, the embodiment of the present application can detect abnormal logs more easily without using prior knowledge. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] The accompanying drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the embodiments of the present application, and together with the description are used to explain the principles of the embodiments of the present application.
[0035] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0036] Figure 1 A flowchart of the first embodiment of the abnormal log detection method of the present application is provided;
[0037] Figure 2 This is a schematic diagram of a scenario of an embodiment of an abnormal log detection method according to an embodiment of the present application;
[0038] Figure 3 This is a flowchart of a specific embodiment of the abnormal log detection method of the present application embodiment;
[0039] Figure 4 This is a schematic diagram of the module structure of the abnormal log detection system according to an embodiment of the present application;
[0040] Figure 5 This is a schematic diagram of the device structure of the hardware operating environment involved in the abnormal log detection method in the embodiment of the present application.
[0041] The purpose, features and advantages of the embodiments of the present application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0042] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0043] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0044] The main solution of the embodiment of the present application is: divide each log to be detected into each log word, and convert each log word into numbers to obtain a digital sequence corresponding to each log to be detected; divide each digital sequence into clusters, wherein the similarity between the non-cluster center digital sequence and the digital sequence corresponding to the cluster center in the same cluster is greater than or equal to a preset similarity threshold, and the same digital sequence does not exist in multiple clusters; the cluster corresponding to the log marked abnormal by the user in each log to be detected is taken as an abnormal cluster, and the log to be detected corresponding to the digital sequence in the abnormal cluster is taken as an abnormal log.
[0045] In this embodiment, for ease of description, the following description is made with the abnormal log detection device as the execution subject.
[0046] Since the prior art requires the use of prior knowledge and a large amount of data to build an anomaly detection algorithm model, abnormal log detection is relatively complicated. The embodiment of the present application provides a new abnormal log detection method, which can classify each log to be detected without prior knowledge, and then can determine all the logs to be detected in the cluster corresponding to the selected abnormal log as abnormal logs based on the abnormal log selected by the user.
[0047] It can be seen from the above embodiments that the embodiments of the present application adopt a technical means of clustering the logs to be detected by the similarity of digital sequences, thereby overcoming the technical problem of traditional abnormal log detection that requires prior knowledge for anomaly detection, thereby achieving the technical effect of automatically detecting abnormal logs without prior knowledge.
[0048] It should be noted that the execution subject of this embodiment can be an abnormal log detection device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, a server, etc. The following takes the server as an example to illustrate this embodiment and the following embodiments.
[0049] Based on this, the present application embodiment provides a method for detecting abnormal logs. Figure 1 , Figure 1 This is a flow chart of the first embodiment of the abnormal log detection method of the present application.
[0050] In this embodiment, the abnormal log detection method includes steps S10 to S30:
[0051] Step S10, dividing each log to be detected into log words, and converting each log word into numbers to obtain a digital sequence corresponding to each log to be detected;
[0052] It should be noted that the log to be detected refers to the log that has not been detected for abnormal logs. For example, when the log is manually detected for abnormal logs, the abnormal logs will be marked. At this time, the log to be detected can also be a log without annotations.
[0053] In addition, log segmentation is a processing unit in the log to be detected. For example, log segmentation can be a word in the log to be detected, and a word refers to a single word or multiple words in the log. It can be understood that a single log to be detected is a statement, and the statement can be split to obtain multiple log segmentations, and then the position of the log segmentation in the statement is replaced by a number corresponding to the log segmentation, so as to obtain a digital sequence corresponding to the single log to be detected.
[0054] It should also be noted that when splitting a statement to obtain multiple log segmentation words, if the log to be detected is an English statement, the statement can be split into multiple log segmentation words according to the spaces in the English statement. In this case, a log segmentation word is a word. Of course, the length of the log segmentation word can also be set. For example, when the length of the log segmentation word is 2, the words in the English statement can be combined with a length of 2 to obtain multiple log segmentation words. In this case, a log segmentation word is 2 words.
[0055] For example, in the scenario where the length of the log segmentation is 2, the log to be detected can be divided into multiple log segmentations by sliding the window. At this time, the size of the sliding window is 2, and multiple log segmentations of length 2 can be obtained by sliding once every 1 word. At this time, the three logs can be converted into log segmentations as follows:
[0056] metax nm-dispatcher|req:1|connectivity change|start running|orderedscripts;
[0057] metax nm-dispatcher|req:1|connectivity-change|start running|orderedscripts;
[0058] metax systemd[1]|Starting Network|Manager Script|Dispatcher Service;
[0059] Among them, | is used to separate two adjacent log words.
[0060] It should be noted that the above method of dividing the sentence to be detected into multiple words is compared with the method of dividing the sentence to be detected into a single word. Since each log word segment consists of multiple words, the data semantics is higher and the sparsity is lower, which can better represent the semantics of the log to be detected. Therefore, the method of dividing the sentence to be detected into multiple words can improve the accuracy of subsequent classification (clustering).
[0061] In addition, when converting log segmentation words into numbers, the numbers can be pre-set and correspond to the log segmentation words one by one. That is, the same log segmentation word corresponds to the same number. In an embodiment of the present application, the way of converting log segmentation words into numbers can not only convert text data into a format that can be processed by a computer, but also ensure that all log data are compared and calculated on the same dimension and scale, thereby improving the accuracy of comparison and calculation. Moreover, directly converting log segmentation words into numbers can also capture the semantic and contextual relationships between log segmentation words. Thus, converting log segmentation words into numbers can also improve the accuracy of subsequent classification.
[0062] Step S20, dividing each of the digital sequences into clusters, wherein the similarity between the non-cluster center digital sequences and the digital sequences corresponding to the cluster center in the same cluster is greater than or equal to a preset similarity threshold, and the same digital sequence does not exist in multiple clusters;
[0063] In this embodiment, the digital sequences can be traversed and the traversed digital sequences can be used as cluster centers, and then the digital sequences can be divided into multiple clusters according to the cluster centers. The digital sequences can also be divided into multiple clusters by randomly selecting cluster centers and calculating the similarities between other digital sequences and the cluster centers.
[0064] It should be noted that when determining the similarity between two digital sequences, it can be calculated by methods such as cosine similarity and Euclidean distance, and the embodiments of the present application do not limit this.
[0065] Exemplarily, when 10 digital sequences are divided into clusters, when the currently traversed digital sequence is the first digital sequence, the similarity between the second to tenth digital sequences and the first digital sequence will be obtained, and then each similarity will be compared with a preset similarity threshold, and the digital sequences corresponding to each similarity greater than the preset similarity threshold will be divided into a cluster. For example, when the similarity between the second digital sequence and the first digital sequence is greater than the threshold, and the similarity between the third digital sequence and the first digital sequence is greater than the threshold, the second digital sequence and the third digital sequence can be divided into a cluster, and the first digital sequence is used as the cluster center of the cluster. Then, in order to reduce the amount of data for calculating the similarity, the digital sequences that have been classified can be skipped for traversal, that is, the fourth digital sequence is used as the current traversal item, and the similarity between the fifth to tenth digital sequences and the fourth digital sequence is calculated, thereby obtaining a cluster with the fourth digital sequence as the cluster center.
[0066] In this embodiment, the embodiment of the present application performs classification based on the existing logs to be detected, which can realize the classification of fewer logs to be detected and the classification of more logs to be detected, avoiding the defects of traditional abnormal log detection algorithms that require a large amount of data support and prior knowledge.
[0067] In a feasible implementation manner, the above step S20 further includes steps S201 to S202.
[0068] Step S201, determining the first number of the number sequence corresponding to the cluster center, the second number of the number sequence of non-cluster center, and the third number of the same number in the number sequence of the cluster center and the number sequence of non-cluster center;
[0069] It should be noted that the number of digits refers to the number of digits in the digit sequence. For example, when the digit sequence is 34, 56, 78, 74, 58, the number of digits is 5.
[0070] Step S202, calculating the sum of the first number of digits and the second number of digits, and taking the ratio of the third number of digits to the sum as the similarity between the non-cluster center digit sequence and the cluster center digit sequence.
[0071] Exemplarily, the formula for calculating similarity may be:
[0072]
[0073] Among them, simi_score is the similarity, Si refers to the digital sequence of the cluster center, Sj refers to the digital sequence of the non-cluster center, len(Si) represents the number of digits in Si, len(Sj) represents the number of digits in Sj, ∩ represents the same number in the two digital sequences, 2 represents the expansion coefficient, and the value of the expansion coefficient is not limited in the embodiment of the present application.
[0074] It is worth mentioning that, compared with the traditional method of calculating similarity using cosine similarity, Euclidean distance, etc., the similarity calculation method proposed in the embodiment of the present application is proposed for digital sequences, and the similarity can be judged by the overlap of numbers in the digital sequence. Since the embodiment of the present application only needs to calculate the number of overlaps of numbers, when calculating the similarity, the amount of calculation is smaller than that of cosine similarity or Euclidean distance, and the efficiency of calculating the similarity is higher.
[0075] Step S30: taking the cluster corresponding to the log marked abnormal by the user in each of the logs to be detected as an abnormal cluster, and taking the log to be detected corresponding to each of the digital sequences in the abnormal cluster as an abnormal log.
[0076] Exemplarily, after the digital sequences corresponding to the logs to be detected are divided into multiple clusters, if it is detected that the user performs an abnormal log screening operation on the logs to be detected, a certain log to be detected is marked as an abnormal log, the cluster where the log selected by the user is located is taken as the abnormal cluster, and the logs to be detected corresponding to the digital sequences in the abnormal cluster are taken as abnormal logs.
[0077] The embodiment of the present application obtains each log to be detected, and divides each log to be detected into each log word, and converts each log word into a number, so as to obtain the digital sequence corresponding to each log to be detected, and can convert the log to be detected into a digital sequence for computer recognition; then divide each digital sequence into each cluster, wherein the similarity between the non-cluster center digital sequence and the digital sequence corresponding to the cluster center in the same cluster is greater than or equal to the preset similarity threshold, and the same digital sequence does not exist in multiple clusters, and can divide the digital sequences with high similarity into the same cluster without prior knowledge, that is, divide the logs to be detected with high similarity into the same cluster; then the cluster corresponding to the log selected by the user in each log to be detected is used as an abnormal cluster, and the log to be detected corresponding to the digital sequence in the abnormal cluster is used as an abnormal log, and the log to be detected with high similarity to the log selected by the user can be automatically identified as an abnormal log under the premise that the user selects an abnormal log in the log to be detected. Thus, the embodiment of the present application can detect abnormal logs more easily without using prior knowledge.
[0078] Further, based on the first embodiment of the abnormal log detection method of the embodiment of the present application, a second embodiment of the abnormal log detection method of the embodiment of the present application is proposed. In the second embodiment of the embodiment of the present application, the same or similar contents as the first embodiment can be referred to the above introduction, and will not be repeated later.
[0079] In this embodiment, in a feasible implementation manner, the above step S10 also includes step S101.
[0080] Step S101, calculating the word frequency corresponding to each of the log segmentations, and composing the word frequencies corresponding to the log segmentations into a digital sequence corresponding to the log to be detected according to the order of the log segmentations in the log to be detected, wherein the word frequency and the log segmentation are in a one-to-one correspondence.
[0081] It should be noted that the word frequency refers to the number of times the log word appears in each log to be detected. For example, if the number of times the log word 'metax nm-dispatcher' appears in 10 logs to be detected is 50, then the word frequency of 'metaxnm-dispatcher' is 50.
[0082] Exemplarily, after calculating the word frequency of each log word in each log to be detected, the word frequency can be used to replace the log word, so that each log word in the log to be detected is converted into a number to obtain a digital sequence. For example, use 50 to replace 'metax nm-dispatcher' in each log to be detected. In this way, in the log metax nm-dispatcher|req:1|connectivity change|start running|ordered scripts, when the word frequencies of 'req:1', 'connectivity change', 'start running' and 'start running' in all logs to be detected are 20, 30, 70, 10 respectively, the digital sequence corresponding to the log metax nm-dispatcher|req:1|connectivity change|start running|ordered scripts is 50, 20, 30, 70, 10.
[0083] It should be noted that when the server processing performance is poor, after using word frequency instead of log word segmentation, the word frequency with a smaller word frequency value can be modified to a special character that does not participate in the similarity calculation, such as **. In addition, it is also possible to deduplicate the exact same numeric sequences. In this way, log word segmentations with fewer occurrences and repeated numeric sequences can be ignored, thereby increasing the speed of calculating similarity.
[0084] In this embodiment, compared with the method of directly using a preset number to replace a certain log segmentation word, the embodiment of the present application uses word frequency to replace the log segmentation method, which not only avoids the step of setting the correspondence between numbers and log segmentation words, but also can judge the frequency of occurrence of log segmentation words in the log based on word frequency, and then judge whether the log is abnormal based on the meaning of the log segmentation words with a higher number of occurrences, thereby improving the accuracy of judging whether the log is abnormal.
[0085] In a feasible implementation manner, the above step S101 may also be replaced by step S102.
[0086] Step S102, map each of the log segmentations to the same vector space to obtain a real number vector corresponding to each of the log segmentations, and organize the real number vectors corresponding to each of the log segmentations into a digital sequence corresponding to each of the log segmentations according to the order of the log segmentations in the log to be detected, wherein the real number vectors and the log segmentations are in a one-to-one correspondence.
[0087] In this embodiment, in order to retain the contextual relationship in the log to be detected, the log word segmentation in the log to be detected can also be mapped to the vector space, so as to obtain the digital expression of the log word segmentation in the vector space, that is, to obtain a real number vector.
[0088] It should be noted that, since the embodiment of the present application uses real vectors instead of log segmentation, the embodiment of the present application can use cosine similarity and Euclidean distance to calculate the similarity of the digital sequence composed of real vectors when calculating the similarity later. In addition, since the real vector retains the contextual relationship of the log segmentation, the similarity will be more accurate when the similarity is calculated later, so that the logs to be detected can be accurately classified and the efficiency of anomaly detection can be improved.
[0089] In a feasible implementation manner, before the above step S20, step S100 and step S200 are also included.
[0090] Step S100, respectively counting the number of numbers contained in each of the digital sequences, and determining the maximum number among the numbers;
[0091] Step S200, using preset numbers to fill in the number sequences in which the number of numbers in each of the number sequences is less than the maximum number, so that the number of numbers in each of the number sequences after filling reaches the maximum number.
[0092] It should be noted that the preset number refers to a number that is not associated with log segmentation. That is to say, when word frequency is used instead of log segmentation, the preset number is a number that is not related to word frequency. For example, in multiple logs to be detected, when the word frequency is only 23, 50, 30, and 70, the preset number can be any number other than 23, 50, 30, and 70. In a feasible embodiment, the preset number can be 0.
[0093] For example, assuming that there are 10 logs to be detected, and after the logs to be detected are converted into digital sequences, the maximum number of digits is 50, then the number 0 can be used to fill the digital sequence with a number less than 50 until the number of digits in the filled digital sequence is 50.
[0094] In this embodiment, the embodiment of the present application adjusts the number of digits in the digital sequence to make the number of digits in the digital sequence consistent, thereby avoiding the problem of large similarity calculation errors caused by inconsistent number of digits, thereby improving the probability of subsequent accurate classification of the digital sequence.
[0095] Furthermore, based on the first embodiment and / or the second embodiment of the abnormal log detection method of the embodiment of the present application, a third embodiment of the abnormal log detection method of the embodiment of the present application is proposed.
[0096] In this embodiment, after the above step S30, the method further includes steps S300 to S500.
[0097] Step S300, after obtaining the target log, the target log is divided into target log segment words, and each target log segment word is converted into a number to obtain a target number sequence, wherein the target log refers to a newly received log that has not been divided into clusters;
[0098] It should be noted that the target digital sequence refers to the digital sequence corresponding to the target log.
[0099] Step S400, determining the similarities between the target digital sequence and the cluster centers of the clusters, and determining the maximum similarity among the similarities;
[0100] Step S500: If it is detected that the maximum similarity is greater than or equal to the preset similarity threshold, the cluster center corresponding to the maximum similarity is used as the target cluster center, and the target digital sequence is divided into the cluster corresponding to the target cluster center.
[0101] In this embodiment, on the premise that the logs to be detected have been clustered, the newly received logs that have not been clustered can be classified based on the existing clusters, thereby quickly identifying whether the newly received logs are abnormal logs.
[0102] It is worth mentioning that, after calculating the similarity between the target digital sequence and each cluster core, and determining the maximum similarity, the embodiment of the present application does not directly divide the target digital sequence into the cluster corresponding to the maximum similarity. The reason is that if the numerical value of the maximum similarity is small, it proves that the similarity between the target digital sequence and the existing cluster core is not high, and directly dividing the target digital sequence into the cluster corresponding to the maximum similarity will reduce the accuracy of classification. Therefore, the embodiment of the present application also sets a similarity threshold to judge whether the similarity of different digital sequences meets expectations, and only under the condition that the maximum similarity is greater than the preset similarity threshold, the target digital sequence will be divided into the cluster corresponding to the maximum similarity. Of course, when the maximum similarity is less than the preset similarity threshold, it is possible to take the target digital sequence as the cluster core, establish a new cluster, and classify the new log based on the newly established cluster and each cluster obtained based on the log to be detected.
[0103] In addition, since there are usually certain similarities between normal operation logs (indicated by the same characters appearing in certain positions of the logs), and abnormal logs are disorganized and have no correlation between logs, when a target digital sequence with a low similarity to an existing cluster is detected, the target log corresponding to the target digital sequence can also be output as a suspected abnormal log for user confirmation.
[0104] In this embodiment, the embodiment of the present application can quickly perform abnormal log detection on the newly received logs by dividing the newly received logs into existing clusters or new clusters, thereby quickly identifying abnormal logs in the newly received logs.
[0105] Furthermore, based on the first embodiment, the second embodiment and the third embodiment proposed in the above-mentioned abnormal log detection method in the embodiment of the present application, a specific embodiment of the abnormal log detection method in the embodiment of the present application is proposed.
[0106] Please refer to Figure 2 , Figure 2 This is a scenario diagram of an embodiment of an abnormal log detection method of an embodiment of the present application, wherein, after obtaining unlabeled logs from a log database, an abnormal log detection device will detect the unlabeled logs to obtain abnormal logs.
[0107] Please refer to Figure 3 , the steps of this specific embodiment are as follows:
[0108] Step A, initialize the two-dimensional data of log word segmentation with n rows and m columns, recorded as log[n][m], where n is the number of log entries and m is the number of log word segmentations;
[0109] Step B, For loop traverses each unlabeled log data;
[0110] Step C, preprocessing the log data, segmenting each log data by sliding the window with a window size of 2 and a step size of 1, and obtaining m log segmentation words for each data segmentation;
[0111] Step D, assign the word frequency of each log word to each element of the corresponding row of the matrix;
[0112] Step E, obtaining a two-dimensional matrix, wherein each row of the two-dimensional matrix represents a digital sequence;
[0113] Step F, calculate the similarity between each digital sequence in the two-dimensional matrix and other digital sequences, so as to divide the digital sequences in the two-dimensional matrix into multiple clusters, and obtain the cluster centers corresponding to the multiple clusters. The method for calculating the cluster centers and clusters in this step is Figure 3 The correspondence is calculated by the KCC algorithm (K-Cluster center, a center of a clustering algorithm);
[0114] Step G, receiving a new log (target log), and converting the new log into a digital sequence, and then classifying the new log based on the known multiple clusters and cluster centers. Figure 3 The corresponding CCM algorithm (Cluster Center Means, calculates the center of the cluster) and then classifies;
[0115] Step H: If it is detected that the cluster where the new log is located has been marked as an abnormal cluster by the user, the new log is treated as an abnormal log.
[0116] In a feasible implementation, the above steps G and H may also be encapsulated into a model to obtain an anomaly detection model.
[0117] It should be noted that the above examples are only used to understand the embodiments of the present application and do not constitute a limitation on the abnormal log detection method of the embodiments of the present application. More simple transformations based on this technical concept are all within the protection scope of the embodiments of the present application.
[0118] The present application also provides an abnormal log detection system. Figure 4 , the abnormal log detection system includes:
[0119] The character conversion module 10 is used to divide each log to be detected into log words, and convert each log word into numbers to obtain a digital sequence corresponding to each log to be detected;
[0120] The log classification module 20 is used to divide each of the digital sequences into clusters, wherein the similarity between the non-cluster center digital sequences and the digital sequences corresponding to the cluster center in the same cluster is greater than or equal to a preset similarity threshold, and the same digital sequence does not exist in multiple clusters;
[0121] The detection module 30 is used to take the cluster corresponding to the log marked abnormal by the user in each of the logs to be detected as an abnormal cluster, and take the log to be detected corresponding to each of the digital sequences in the abnormal cluster as an abnormal log.
[0122] In one embodiment, the log classification module is further used to:
[0123] Determine a first number of the number sequence corresponding to the cluster center, a second number of the number sequence of non-cluster centers, and a third number of the same numbers in the number sequence of the cluster center and the number sequence of non-cluster centers;
[0124] The sum of the first number of digits and the second number of digits is calculated, and the ratio of the third number of digits to the sum is used as the similarity between the non-cluster center digit sequence and the cluster center digit sequence.
[0125] In one embodiment, the abnormal log detection system includes:
[0126] A data acquisition module, used to acquire each cluster and the cluster center corresponding to each cluster;
[0127] A target log conversion module is used to divide the target log into target log words after obtaining the target log, and convert each target log word into a number to obtain a target number sequence, wherein the target log refers to a newly received log that has not been divided into clusters;
[0128] A similarity calculation module, used to determine the similarities between the target digital sequence and the cluster centers of the clusters, and to determine the maximum similarity among the similarities;
[0129] The target log classification module is used to, if it is detected that the maximum similarity is greater than or equal to the preset similarity threshold, take the cluster center corresponding to the maximum similarity as the target cluster center, and divide the target digital sequence into the cluster corresponding to the target cluster center.
[0130] In one embodiment, the character conversion module 10 is further used for:
[0131] The word frequencies corresponding to the log segmentations are calculated, and according to the order of the log segmentations in the log to be detected, the word frequencies corresponding to the log segmentations are combined into a digital sequence corresponding to the log to be detected.
[0132] In one embodiment, the character conversion module 10 is further used for:
[0133] Map each of the log word segments to the same vector space to obtain a real number vector corresponding to each of the log word segments; and according to the order of each of the log word segments in the log to be detected, organize the real number vectors corresponding to each of the log word segments into a digital sequence corresponding to each of the logs to be detected.
[0134] In one embodiment, the abnormal log detection system includes:
[0135] A quantity calculation module, used to count the number of numbers contained in each of the digital sequences, and determine the maximum number among the numbers;
[0136] The filling module is used to use preset numbers to fill in the number sequences in which the number of numbers in each of the number sequences is less than the maximum number, so that the number of numbers in each of the number sequences after filling reaches the maximum number.
[0137] The abnormal log detection system provided in the embodiment of the present application adopts the abnormal log detection method in the above embodiment, which can solve the technical problem of low abnormal log detection efficiency. Compared with the prior art, the beneficial effects of the abnormal log detection system provided in the embodiment of the present application are the same as the beneficial effects of the abnormal log detection method provided in the above embodiment, and other technical features in the abnormal log detection system are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0138] An embodiment of the present application provides an abnormal log detection device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the abnormal log detection method in the above-mentioned embodiment one.
[0139] Reference below Figure 5 , which shows a schematic diagram of the structure of an abnormal log detection device suitable for implementing the embodiment of the present application. The abnormal log detection device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The abnormal log detection device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0140] like Figure 5 As shown, the abnormal log detection device may include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the abnormal log detection device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the abnormal log detection device to communicate with other devices wirelessly or wired to exchange data. Although the abnormal log detection device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided alternatively.
[0141] In particular, according to the embodiments disclosed in the embodiments of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the embodiments of the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through a communication device, or installed from the storage device 1003, or installed from the ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the embodiment of the present application are executed.
[0142] The abnormal log detection device provided in the embodiment of the present application adopts the abnormal log detection method in the above embodiment, which can solve the technical problem of low abnormal log detection efficiency. Compared with the prior art, the beneficial effects of the abnormal log detection device provided in the embodiment of the present application are the same as the beneficial effects of the abnormal log detection method provided in the above embodiment, and other technical features in the abnormal log detection device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0143] It should be understood that the various parts disclosed in the embodiments of the present application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0144] The above is only a specific implementation of the embodiment of the present application, but the protection scope of the embodiment of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or replacements within the technical scope disclosed in the embodiment of the present application, which should be included in the protection scope of the embodiment of the present application. Therefore, the protection scope of the embodiment of the present application should be based on the protection scope of the claims.
[0145] An embodiment of the present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the abnormal log detection method in the above embodiment.
[0146] The computer-readable storage medium provided in the embodiment of the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.
[0147] The computer-readable storage medium may be included in the abnormal log detection device; or may exist independently without being assembled into the abnormal log detection device.
[0148] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the abnormal log detection device, the abnormal log detection device: obtains each log to be detected, and divides each log to be detected into log words, and converts each log word into numbers to obtain a digital sequence corresponding to each log to be detected; divides each digital sequence into clusters, wherein the similarity between the non-cluster center digital sequence and the digital sequence corresponding to the cluster center in the same cluster is greater than or equal to a preset similarity threshold, and the same digital sequence does not exist in multiple clusters; the cluster corresponding to the log marked abnormal by the user in each log to be detected is taken as an abnormal cluster, and the log to be detected corresponding to each digital sequence in the abnormal cluster is taken as an abnormal log.
[0149] The computer program code for performing the operation of the embodiment of the present application can be written in one or more programming languages or a combination thereof, and the above-mentioned programming languages include object-oriented programming languages, such as Java, Smalltalk, C++, and also include conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on the remote computer, or completely on the remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).
[0150] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the function marked in the box can also occur in a different order from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0151] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0152] The readable storage medium provided in the embodiment of the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned abnormal log detection method, and can solve the technical problem of low abnormal log detection efficiency. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the embodiment of the present application are the same as the beneficial effects of the abnormal log detection method provided in the above-mentioned embodiment, and will not be repeated here.
[0153] An embodiment of the present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned abnormal log detection method when executed by a processor.
[0154] The computer program product provided in the embodiment of the present application can solve the technical problem of low efficiency of abnormal log detection. Compared with the prior art, the beneficial effects of the computer program product provided in the embodiment of the present application are the same as the beneficial effects of the abnormal log detection method provided in the above embodiment, which will not be repeated here.
[0155] The above descriptions are only some embodiments of the embodiments of the present application, and do not limit the patent scope of the embodiments of the present application. All equivalent structural transformations made by using the description and drawings of the embodiments of the present application under the technical concept of the embodiments of the present application, or directly / indirectly applied in other related technical fields are included in the patent protection scope of the embodiments of the present application.
Claims
1. A method for detecting abnormal logs, characterized in that: The method includes: Divide each log to be detected into log words, and convert each log word into numbers to obtain a digital sequence corresponding to each log to be detected; Dividing each of the digital sequences into clusters, wherein the similarity between the non-cluster center digital sequences and the digital sequences corresponding to the cluster center in the same cluster is greater than or equal to a preset similarity threshold, and the same digital sequence does not exist in multiple clusters; The cluster corresponding to the log marked abnormal by the user in each of the logs to be detected is taken as an abnormal cluster, and the log to be detected corresponding to each of the digital sequences in the abnormal cluster is taken as an abnormal log.
2. The method according to claim 1, characterized in that The steps of calculating the similarity between the non-cluster center digital sequence and the digital sequence corresponding to the cluster center in the same cluster include: Determine a first number of the number sequence corresponding to the cluster center, a second number of the number sequence of non-cluster centers, and a third number of the same numbers in the number sequence of the cluster center and the number sequence of non-cluster centers; The sum of the first number of digits and the second number of digits is calculated, and the ratio of the third number of digits to the sum is used as the similarity between the non-cluster center digit sequence and the cluster center digit sequence.
3. The method according to claim 1, characterized in that After the step of dividing each of the digital sequences into clusters, the method further includes: After obtaining the target log, the target log is divided into target log words, and each target log word is converted into a number to obtain a target number sequence, wherein the target log refers to a newly received log that has not been divided into clusters; Determine the similarities between the target digital sequence and the cluster centers of the clusters, and determine the maximum similarity among the similarities; If it is detected that the maximum similarity is greater than or equal to the preset similarity threshold, the cluster center corresponding to the maximum similarity is used as the target cluster center, and the target digital sequence is divided into the cluster corresponding to the target cluster center.
4. The method according to claim 1, characterized in that The step of converting each of the log segment words into numbers to obtain a number sequence corresponding to the log to be detected includes: The word frequencies corresponding to the log segmentations are calculated, and according to the order of the log segmentations in the log to be detected, the word frequencies corresponding to the log segmentations are combined into a digital sequence corresponding to the log to be detected.
5. The method according to claim 1, characterized in that The step of converting each of the log segment words into numbers to obtain a number sequence corresponding to the log to be detected includes: Map each of the log word segments to the same vector space to obtain a real number vector corresponding to each of the log word segments; and according to the order of each of the log word segments in the log to be detected, organize the real number vectors corresponding to each of the log word segments into a digital sequence corresponding to each of the logs to be detected.
6. The method according to any one of claims 1 to 5, characterized in that Before the step of dividing each of the digital sequences into clusters, the method further comprises: Counting the number of numbers contained in each of the digital sequences respectively, and determining the maximum number among the numbers; Use preset numbers to fill in the number sequences in which the number of numbers in each of the number sequences is less than the maximum number, so that the number of numbers in each of the number sequences after filling reaches the maximum number.
7. An abnormal log detection system, characterized in that: The system comprises: A character conversion module is used to divide each log to be detected into log words, and convert each log word into a number to obtain a digital sequence corresponding to each log to be detected; A log classification module, used for dividing each of the digital sequences into clusters, wherein the similarity between the non-cluster center digital sequences and the digital sequences corresponding to the cluster center in the same cluster is greater than or equal to a preset similarity threshold, and the same digital sequence does not exist in multiple clusters; The detection module is used to take the cluster corresponding to the log marked abnormal by the user in each of the logs to be detected as an abnormal cluster, and take the log to be detected corresponding to each digital sequence in the abnormal cluster as an abnormal log.
8. An abnormal log detection device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the abnormal log detection method according to any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the abnormal log detection method according to any one of claims 1 to 6 are implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the abnormal log detection method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Data exception detection method and device, computer readable storage medium and computer equipment
CN110245132A
Abnormal log detection method, device and equipment and computer readable storage medium
CN112235327A
Abnormal log processing method and device
CN115422000A
Abnormal log event detection and prediction
US20230004750A1
Cited By
Smart home behavior classification and anomaly detection method and device
CN120034352A
