Abnormal log alarm method and device

By generating log public pattern collection and clustering technology, it automatically identifies the matching between new logs and public patterns, solving the problems of heavy workload and low accuracy caused by manual definition of log syntax, and realizing real-time abnormal log alarms without manual participation. Improved alarm efficiency and accuracy.

CN114518983BActive Publication Date: 2024-09-24DIANKEYUN (BEIJING) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011204680.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-02
Publication Date
2024-09-24
Estimated Expiration
2040-11-02

AI Technical Summary

Technical Problem

In the existing technology, abnormal log alarms require developers to manually define log syntax, which results in a heavy workload and the possibility of missing log syntax, making it impossible to accurately obtain log abnormal information, and it is especially difficult to achieve real-time alarms without supervision.

Method used

By generating a public pattern set of logs, clustering normal logs based on log patterns, calculating the distance between logs, and determining whether the new log matches the public pattern. If not, an alarm message is generated, realizing real-time alarm rule formulation without manual participation. Abnormal log alert.

Benefits of technology

It achieves efficient real-time abnormal log alarms, saves manpower, avoids possible erroneous rules, and improves the accuracy and automated processing capabilities of log abnormal information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114518983B
    Figure CN114518983B
Patent Text Reader

Abstract

The present invention provides an abnormal log alarm method and device, the method comprising the following steps: extracting logs from a log library, and when it is determined that the established log pattern set does not contain a matching log pattern, adding the extracted log to the log pattern set; performing pattern clustering on the extracted logs to obtain a log set of one or more patterns clustered according to the log pattern; generating a log common pattern corresponding to each log pattern based on the common pattern of each log in the log set of each pattern, and generating a log common pattern set based on the common pattern corresponding to each log pattern; receiving a new log; determining whether the new log is an abnormal log based on whether the new log matches the log common pattern in the log common pattern set; and generating an alarm message if it is determined to be an abnormal log. The present invention can efficiently realize real-time abnormal log alarm without the need to participate in the formulation of alarm rules, saving manpower, and avoiding possible erroneous rules.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to an abnormal log alarm method and device. Background Art

[0002] Generally, abnormal log alarms are generated by developers manually defining log syntax, marking abnormal logs based on the manually defined log syntax, and generating alarms when abnormal logs appear. This method requires developers to spend a lot of effort to define log types, and manually define the corresponding problems when alarms appear, which increases the workload of developers. If programmers miss defining some log syntax, the system often cannot accurately obtain log abnormal information.

[0003] Therefore, how to realize the alarm of abnormal logs without supervision is an urgent problem to be solved. Summary of the invention

[0004] In view of the problems existing in the prior art, the embodiments of the present invention provide an abnormal log alarm method and device to efficiently implement real-time abnormal log alarm without the need to participate in the formulation of alarm rules, saving manpower and avoiding possible erroneous rules.

[0005] The technical solution of the present invention is as follows:

[0006] An abnormal log alarm method, the method comprising the following steps:

[0007] Log common pattern set generation step: for multiple normal logs in the log library, determine the log mode to which each normal log belongs, and generate a log common pattern set based on the normal logs of each log mode; the log common pattern set generation step includes:

[0008] Extracting normal logs from the log library, determining whether the established log pattern set contains a log pattern that matches the extracted log, and adding the extracted log to the log pattern set if it is determined that the log pattern set does not contain a log pattern that matches the extracted log;

[0009] Clustering the extracted normal logs based on the log pattern to obtain a log set of one or more log patterns clustered according to the log pattern; and

[0010] Generate a log common pattern corresponding to each log pattern based on the common pattern of each log in the log set of each log pattern, and generate a log common pattern set based on the common pattern corresponding to each log pattern;

[0011] Receive new logs;

[0012] Determine whether the received new log matches a log common pattern in the log common pattern set, and determine whether the received new log is an abnormal log based on the matching result;

[0013] When it is determined that the received new log is an abnormal log, an alarm message is generated.

[0014] In one embodiment of the present invention, the determining whether the established log pattern set contains the log pattern that matches the extracted log, and if it is determined that the log pattern set does not contain the log pattern that matches the extracted log, adding the extracted log to the log pattern set includes: determining whether the log pattern set is empty, and if it is determined that the log pattern set is empty, adding the extracted log to the log pattern set; if it is determined that the log pattern set is not empty, determining whether the log pattern set contains the log pattern that matches the extracted log based on a comparison of the distance between the extracted log and the logs in the log pattern set with a predetermined distance threshold, and if it is determined that the log pattern set does not contain the log pattern that matches the extracted log, adding the extracted log to the log pattern set.

[0015] In one embodiment of the present invention, the method of determining whether the log pattern set contains a log pattern that matches the extracted log based on the comparison between the distance between the extracted log and the logs in the log pattern set and a predetermined distance threshold comprises: selecting logs one by one from the log pattern set in a predetermined order, and determining the length of the extracted log and the currently selected log based on the number of words; determining the number of identical words in the extracted log and the currently selected log; calculating the distance between the two logs based on the ratio of the number of identical words in the extracted log and the currently selected log and the larger length of the two logs; and determining whether the log pattern set contains the log pattern that matches the extracted log based on the comparison between the calculated distance and the predetermined distance threshold.

[0016] In one embodiment of the present invention, the distance between the two logs is calculated based on the following formula: score(logi,logj)=1-match(logi,logj) / max(len(logi),len(logj)); wherein logi and logj represent two logs respectively, score(logi,logj) represents the distance between the two logs, match(logi,logj) represents the number of identical words in the two logs, and max(len(logi),len(logj)) represents the larger length of the two logs.

[0017] In one embodiment of the present invention, a log common pattern corresponding to each log pattern is generated based on the common pattern of each log in the log set of each log pattern, and a log common pattern set is generated based on the common patterns corresponding to each log pattern, including: for each log set of log pattern, when the number of logs in the log set is one, the log itself is used as the log common pattern corresponding to the current log set; when there are more than two logs in the log set of the current log pattern, the log common pattern corresponding to each log pattern can be generated in the following manner: two adjacent logs in each log pattern are compared in sequence, the common pattern obtained after comparison is used as the current log common pattern, and the current log common pattern is compared with the next log in sequence, the obtained common pattern is used to update the current log common pattern, and the current log common pattern obtained after traversing all logs is used as the log common pattern corresponding to the current log pattern.

[0018] In one embodiment of the present invention, the determining whether the received new log matches the log common pattern in the log common pattern set, and determining whether the received new log is an abnormal log based on the matching result, includes: comparing the new log with the log common pattern in the log common pattern set; if it is determined that the new log belongs to any log common pattern in the log common pattern set, then determining that the received new log matches the log common pattern in the log common pattern set, thereby determining that the received new log is not an abnormal log; if it is determined that the new log does not belong to any log common pattern in the log common pattern set, then determining that the received new log does not match the log common pattern in the log common pattern set, thereby determining that the received new log is an abnormal log.

[0019] In an embodiment of the present invention, the method further includes: if it is determined that the log pattern set contains a log pattern matching the extracted log, not adding the extracted log to the log pattern set.

[0020] In another aspect of the present invention, an abnormal log alarm device is provided, which includes a processor and a memory, wherein the memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the device implements the steps of the method described above.

[0021] Another aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the above-mentioned method when executed by a processor.

[0022] The abnormal log alarm method and device of the present invention can efficiently realize real-time abnormal log alarm without the need for human participation in alarm rule formulation, thus saving manpower and avoiding possible erroneous rules.

[0023] Additional advantages, purposes, and features of the present invention will be described in part in the following description, and will become apparent to those skilled in the art after studying the following, or may be learned from the practice of the present invention. The purposes and other advantages of the present invention may be achieved and obtained by the structures specifically pointed out in the written description, claims, and drawings.

[0024] Those skilled in the art will appreciate that the objectives and advantages that can be achieved with the present invention are not limited to the above specific description, and the above and other objectives that can be achieved by the present invention will be more clearly understood from the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of this application, and do not constitute a limitation of the present invention.

[0026] Figure 1 The figure is a flow chart of an abnormal log alarm method in one embodiment of the present invention.

[0027] Figure 2 The figure is a flow chart of the steps of generating a log common pattern set in one embodiment of the present invention.

[0028] Figure 3 The figure is a flowchart of the step of determining whether a log pattern set contains a log pattern matching an extracted log in one embodiment of the present invention. DETAILED DESCRIPTION

[0029] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments and the accompanying drawings. Here, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.

[0030] It should also be noted that, in order to avoid obscuring the present invention due to unnecessary details, only structures and / or processing steps closely related to the solutions according to the present invention are shown in the accompanying drawings, while other details that are not closely related to the present invention are omitted.

[0031] It should be emphasized that the term “include / comprises” when used herein refers to the presence of features, elements, steps or components, but does not exclude the presence or addition of one or more other features, elements, steps or components.

[0032] Figure 1 FIG. 1 is a flow chart of an abnormal log alarm method proposed in an embodiment of the present invention. Figure 1 As shown, the abnormal log alarm method includes the following steps:

[0033] Step S110, log common pattern set generation step: for multiple normal logs in the log library, determine the log mode to which each normal log belongs, and generate a log common pattern set based on the normal logs of each log mode.

[0034] In this step, the log mode to which the normal log belongs can be first determined based on the distance between normal logs reflecting the similarity between different normal logs (normal logs with a higher degree of similarity belong to the same log mode), and then the log common mode under each log mode is determined based on the common part of the logs of each log mode, and a log common mode set is generated according to all log common modes of all log modes. The log common mode set is a set of common modes corresponding to normal logs in the log library.

[0035] After determining the log common pattern set, the newly received log can be compared with the log common pattern in the log common pattern set for matching, and based on the matching result, it can be judged whether the new log is a normal log or an abnormal log, so that reminders can be given for daily logs, as described in the following steps.

[0036] Step S120: receiving a new log.

[0037] This step receives new logs as they are generated.

[0038] Step S130 , determining whether the received new log matches a log common pattern in the log common pattern set, and determining whether the received new log is an abnormal log based on the matching result.

[0039] More specifically, if it is determined that the received new log matches the log common pattern in the log common pattern set, it is determined that the received new log is not an abnormal log, that is, a normal log. If it is determined that the received new log does not match the log common pattern in the log common pattern set, it is determined that the received new log is an abnormal log.

[0040] Step S140: if it is determined that the received new log is an abnormal log, generate an alarm message.

[0041] After the alarm information is generated, the alarm information may be sent to related devices or users.

[0042] Through the above process, real-time abnormal log alarms can be automatically and efficiently implemented without the need to participate in the formulation of alarm rules, saving manpower.

[0043] More specifically, as in step S110 above, the flow chart of the log common pattern set generation step is further shown as follows: Figure 2 As shown, this step includes the following steps:

[0044] Step S210, extract normal logs from the log library, determine whether the established log pattern set contains a log pattern that matches (or belongs to) the extracted log, and add the extracted log to the log pattern set if it is determined that the log pattern set does not contain a log pattern that matches the extracted log.

[0045] More specifically, when extracting a normal log in the log library, determine whether the log pattern set used to identify the log pattern type is empty, and if it is empty, directly add the extracted log to the log pattern set. The log pattern set can be established in advance or when the step is first performed.

[0046] If it is determined that the log pattern set is not empty, then whether the log pattern set contains a log pattern that matches the extracted log is determined based on the comparison of the distance between the extracted log and the log in the log pattern set with a predetermined distance threshold, and if it is determined that there is no log pattern that matches the extracted log, the extracted log is added to the log pattern set; and if it is determined that the log pattern set contains a log pattern that matches the extracted log, the extracted log is not added to the log pattern set, that is, the current log pattern set is kept unchanged.

[0047] The elements included in the log mode set are logs, one log corresponds to one log mode, and different logs represent different log modes.

[0048] In one embodiment of the present invention, Figure 3 As shown, the step of determining whether the log pattern set contains a log pattern matching the extracted log according to the comparison between the distance between the extracted log and the log in the log pattern set and a predetermined distance threshold comprises the following steps S310-S330:

[0049] Step S310 , selecting logs one by one from the log pattern set in a predetermined order, and determining the length of the extracted log and the currently selected log based on the number of words.

[0050] Logs are usually separated by spaces, and the number of words separated by spaces is the log length.

[0051] Step S320, determining the number of identical words in the extracted log and the currently selected log.

[0052] The words in the extracted log and the currently selected log are compared in order. If they are the same, add 1 to get the number of identical words, or the number of matching words.

[0053] Step S330 , calculating the distance between the two logs based on the ratio of the number of identical words in the extracted log and the currently selected log to the larger length of the two logs.

[0054] In this way, the ratio of the number of identical words in the extracted log and the selected log to the larger length of the two logs is a value less than or equal to 1. The closer the two logs are, the more identical words there will be in the extracted log and the selected log, so the ratio of the number of identical words in the extracted log and the selected log to the larger length of the two logs will be larger. In comparison, if the two logs are not similar, the number of identical words in the extracted log and the selected log will be smaller, so the ratio of the number of identical words in the extracted log and the selected log to the larger length of the two logs will be smaller. Therefore, the similarity of the two logs can be reflected based on this ratio.

[0055] In order to show that similar logs have a smaller distance and logs with greater differences have a larger distance, as an example, the distance between two logs can be calculated based on the following formula:

[0056] score(logi,logj)=1-match(logi,logj) / max(len(logi),len(logj)) (1);

[0057] Among them, logi and logj represent two logs respectively, score(logi,logj) represents the distance between the two logs, match(logi,logj) represents the number of identical words in the two logs, and max(len(logi),len(logj)) represents the larger length of the two logs.

[0058] The above formula is only an example, but the present invention is not limited thereto, and other variations may also be adopted.

[0059] Step S340 : determining whether the log pattern set contains a log pattern matched by the extracted log based on a comparison between the calculated distance and a predetermined distance threshold.

[0060] For example, when using formula (1) to calculate the distance between two logs, if the calculated distance is greater than a predetermined distance threshold, it means that the extracted log and the selected log pattern are quite different and they do not belong to the same log pattern. By comparing the extracted log with other logs in the log pattern set one by one in order, it is also possible to determine whether the extracted log and the comparison object in the log pattern set belong to the same log pattern.

[0061] By comparing the distance between the extracted log and the logs in the log pattern set with a predetermined distance threshold, if it is determined that a certain log in the log pattern set contains a log pattern that matches the extracted log, it means that the extracted log and the certain log belong to the same log pattern, that is, the log pattern corresponding to the extracted log is already included in the log pattern set, and the extracted log is not added to the log pattern set. If by comparing the distance between the extracted log and the logs in the log pattern set with a predetermined distance threshold, it is determined that all logs in the log pattern set do not contain a log pattern that matches the extracted log, it means that the extracted log and all logs in the log pattern set do not belong to the same log pattern, that is, the log pattern corresponding to the extracted log is not included in the log pattern set, and the extracted log is added to the log pattern set to represent a new log pattern.

[0062] Step S220 , clustering the extracted normal logs based on the log patterns to obtain a log set of one or more log patterns clustered according to the log patterns.

[0063] By comparing the distance between the extracted normal log and the log in the log pattern set with a predetermined distance threshold, the log pattern to which the normal log belongs can be determined, so that the pattern clustering of the extracted normal log according to the log pattern can be achieved. According to the clustering result, a log set of one or more log patterns clustered according to the log pattern can be obtained.

[0064] Step S230 , generating a log common pattern corresponding to each log mode based on the common pattern of each log in the log set of each log mode, and generating a log common pattern set based on the common patterns corresponding to each log mode.

[0065] Generating a log common pattern corresponding to each log pattern is to obtain the common part of each log in each log pattern.

[0066] In one embodiment of the present invention, this step is implemented as follows:

[0067] For each log set of log mode, when the number of logs in the log set is one, the log itself is used as the log common pattern corresponding to the current log set; when there are more than two logs in the log set of the current log mode, the log common pattern corresponding to each log mode can be generated in the following way: compare the two adjacent logs in each log mode in order, use the common pattern obtained after comparison as the current log common pattern, then compare the current log common pattern with the next log in order, update the current log common pattern with the obtained common pattern, and use the current log common pattern obtained after traversing all logs as the log common pattern corresponding to the current log mode. It can also be understood that the first log is selected in order as the current log common pattern, and the current log common pattern is compared with the next log in order to update the log common pattern.

[0068] When comparing logs, if the words are the same, keep the original words, otherwise replace them with "*".

[0069] For example, if a log pattern corresponds to the following two logs:

[0070] LabSZ sshd

[24] :Invalid user webmaster from ip;

[0071] LabSZ sshd

[24] :Invalid user 1from ip;

[0072] The corresponding log public mode is LabSZ sshd

[24] :Invalid user*from ip.

[0073] The log common patterns corresponding to each log pattern are put into a set to generate a log common pattern set.

[0074] The aforementioned step S130 may further include the following steps:

[0075] Compare the received new log with the log common pattern in the log common pattern set, and if it is determined that the new log belongs to any log common pattern in the log common pattern set, then determine that the received new log matches the log common pattern in the log common pattern set, thereby determining that the received new log is not an abnormal log;

[0076] If it is determined that the received new log does not belong to any log common pattern in the log common pattern set, it is determined that the received new log does not match the log common pattern in the log common pattern set, and thus the received new log is determined to be an abnormal log.

[0077] Once a received new log is found to be an abnormal log, an alarm message is generated and an alarm is issued.

[0078] The above abnormal log alarm method can efficiently realize real-time abnormal log alarm without the need to participate in the alarm rule formulation, saving manpower and avoiding possible erroneous rules.

[0079] The abnormal log alarm method according to an embodiment of the present invention is described below with reference to a specific example.

[0080] Assume that the log library contains logs as shown in Table 1 below.

[0081] Table 1. Normal log information in the log library.

[0082]

[0083] Before describing the method flow of this embodiment, the distance between logs, the log mode and the log mode set are described first.

[0084] 1. Calculate the distance between logs, taking log3 and log4 as an example:

[0085] (1) Logs are usually separated by spaces. The number of words separated by spaces is the length of the log.

[0086] Taking log3 as an example, the words obtained after being separated by spaces are ("LabSZ", "sshd

[24] :", "pam_unix(sshd:auth):", "check", "pass;", "user", "unknown"), and the log3 length len(log3) = 7. Similarly, len(log4) = 11.

[0087] (2) Take the larger length of the two logs, max(len(log3),len(log4))=11.

[0088] (3) Compare the words in the two logs in order. If they are the same, add 1 to get match(log3,log4)=3.

[0089] (4) Taking max(len(log3),len(log4)) as the denominator and match(log3,log4) as the numerator, we can use the following formula to calculate score(log3,log4)=1-match(log3,log4) / max(len(log3),len(log4))=0.727. The value of score(log3,log4) (0.727) is the calculated distance between the two logs.

[0090] The calculation formula is only an example, and the present invention is not limited thereto. The coefficients in the formula can be adjusted.

[0091] 2. Determine the log mode

[0092] The log pattern refers to the representative logs in the same category (pattern). Other logs in the same category are not included in the log pattern.

[0093] A distance threshold is defined, and this threshold is used to define whether a new log belongs to a new log mode. If the distance from all modes in the log mode is greater than the distance threshold, it belongs to a new log mode. As an example, distance=0.5 can be set, but the present invention is not limited thereto.

[0094] 3. Log mode collection

[0095] Define a log mode set set = {} to store all log modes.

[0096] Each log mode may correspond to one or more logs. Therefore, the log set corresponding to each log mode may be obtained by clustering based on the log mode.

[0097] The number of log sets corresponding to each log pattern is the same as the number of log patterns, and each log set is used to store logs belonging to the corresponding log pattern, such as pattern1_log={}, pattern2_log={}.

[0098] The abnormal log alarm process of this embodiment includes the following steps:

[0099] (1) Extract normal logs from the log library, determine the log mode to which the extracted log belongs, ensure that the log mode is included in the log mode set, and perform clustering at the same time

[0100] Sequentially extract normal logs from the log library (such as inputting normal logs into the abnormal log alarm program of the present invention). If the log pattern set is empty, put the log into the log pattern set; if the log pattern set is not empty, compare the log with the log pattern in the log pattern set. If the distance between the log and a log pattern in the log pattern set is less than the set distance threshold, keep the log pattern set unchanged, and cluster based on the log pattern to divide the log into the category represented by the log pattern, and put the log into the log set corresponding to the log pattern.

[0101] Taking log1 to log6 as an example, set distance=0.5.

[0102] Step 1: Input log1

[0103] Because the log pattern set set is empty at this time, log1 is put into set, set = {pattern1_log}, where pattern1_log = log1.

[0104] Step 2: Input log2

[0105] score(pattern1_log,log2)=1-match(pattern1_log,log2) / max(len(pattern1_log),len(log2))=2 / 7=0.714;

[0106] score(pattern1_log,log2)>distance;

[0107] Therefore, log2 is put into the log pattern set set, set = {pattern1_log, pattern2_log}, where pattern2_log = log2.

[0108] Step 3: Input log3

[0109] score(pattern1_log,log3)=0.714>distance;

[0110] score(pattern2_log,log3)=0.714>distance;

[0111] Therefore, log3 is put into the log pattern set set, set = {pattern1_log, pattern2_log, pattern3_log}, where pattern3_log = log3.

[0112] Step 4: Enter log4

[0113] score(pattern1_log,log4)=0.818>distance;

[0114] score(pattern2_log,log4)=0.818>distance;

[0115] score(pattern3_log,log4)=0.727>distance;

[0116] Therefore, put log4 into set, set = {pattern1_log, pattern2_log, pattern3_log, pattern4_log}, where pattern4_log = log4.

[0117] Step 5: Input log5

[0118] score(pattern1_log,log5)=0.143 <distance;

[0119] So log5 belongs to the pattern1_log category, the set remains unchanged, and log5 is put into the log set corresponding to pattern1_log.

[0120] Step 6: Input log6

[0121] score(pattern1_log,log6)=0.714>distance;

[0122] score(pattern2_log,log6)=0 <distance;

[0123] So log6 belongs to the pattern2_log category, the set remains unchanged, and log6 is put into the log set corresponding to pattern2_log.

[0124] After all normal logs in the log library are input, the following clustering results are obtained:

[0125] The first type of log pattern represented by pattern1_log includes {log1,log5};

[0126] The second type of log pattern represented by pattern2_log includes {log2,log6};

[0127] The third type of log pattern represented by pattern3_log includes {log3};

[0128] The fourth type of log pattern represented by pattern4_log includes {log4}.

[0129] (2) Determine the common patterns of each type of log and generate a set of common log patterns

[0130] Compare the two adjacent logs in each log pattern in order. If the words are the same, keep the original words, otherwise replace them with "*". Then, use the common pattern obtained after comparison as the log common pattern corresponding to the current category, and then compare the current log common pattern with the next log in order, update the current log common pattern with the obtained common pattern, and use the current log common pattern obtained after traversing all logs as the log common pattern corresponding to the current log pattern.

[0131] 2.1 Common Mode of the First Type of Logs

[0132] The first type of log includes log1 and log5:

[0133] LabSZ sshd

[24] :Invalid user webmaster from ip;

[0134] LabSZ sshd

[24] :Invalid user 1from ip;

[0135] According to the rules given above, the log common pattern is LabSZ sshd

[24] :Invalid user*from ip.

[0136] If the class also contains the third log, assuming it is LabSZ sshd

[24] : Invalid user 1fromtable, the obtained public pattern is compared with the third log when comparing again, and the new public pattern is LabSZsshd

[24] : Invalid user*from*.

[0137] 2.2 Common Mode of the Second Type of Logs

[0138] The second type of logs include log2 and log6:

[0139] Similarly, the common pattern of the second type of log is LabSZ sshd

[24] :Connection closed by ip[preauth].

[0140] 2.3 Common Mode of the Third Type of Logs

[0141] The third type of log contains log3, which has only one log. The public mode of the log is itself, LabSZ sshd

[24] :pam_unix(sshd:auth):check pass; user unknown.

[0142] 2.4 Common Mode of the Fourth Type of Logs

[0143] The fourth type of log includes log4, which has only one log, and the log common mode is itself, LabSZ sshd

[24] :pam_unix(sshd:auth):authentication failure; logname=uid=0euid=0tty=ssh ruser=rhost=ip.

[0144] 2.5 Log Common Mode Collection

[0145] The log common pattern set obtained from the previous log common patterns is {"LabSZ sshd

[24] :Invaliduser*from ip", "LabSZ sshd

[24] :Connection closed by ip[preauth]", "LabSZ sshd

[24] :pam_unix(sshd:auth):check pass; user unknown", "LabSZ sshd

[24] :pam_unix(sshd:auth):authentication failure; logname=uid=0euid=0tty=ssh ruser=rhost=ip"}.

[0146] (3) receiving a new log, determining whether the received new log matches a log common pattern in a log common pattern set, and determining whether the received new log is an abnormal log based on the matching result; and generating an abnormal log alarm if the received new log is determined to be an abnormal log.

[0147] With the log common pattern set, you can use this set to discover abnormal logs. If a new log does not belong to any of the log common patterns in the log common pattern set, it will be marked as an abnormal log and an alarm will be issued. An example is as follows:

[0148] new_log1 = "LabSZ sshd

[24] : Invalid user 4from ip". After comparison with the log common pattern set, it is found that this log belongs to the log common pattern "LabSZ sshd

[24] : Invalid user*from ip" and is not an abnormal log.

[0149] new_log2 = "LabSZ sshd

[24] : Invalid user 1by ip". After comparison with the log common pattern set, it is found that this log does not belong to the log common pattern set and is an abnormal log, so an alarm is issued.

[0150] Corresponding to the aforementioned method, the present invention also provides an abnormal log alarm device, which includes a processor and a memory, wherein the memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the device implements the steps of the method described above.

[0151] The present invention also relates to a storage medium on which computer program code can be stored, and when the program code is executed, various embodiments of the method of the present invention can be implemented. The storage medium can be a tangible storage medium, such as an optical disk, a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM or any other form of tangible storage medium known in the technical field.

[0152] It should be clear that the present invention is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present invention.

[0153] It should be understood by those skilled in the art that the exemplary components, systems and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software or a combination of the two. Whether it is performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention. When implemented in hardware, it can be, for example, an electronic circuit, an application-specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present invention are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium or transmitted on a transmission medium or a communication link via a data signal carried in a carrier. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, and the like. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.

[0154] It should also be noted that the exemplary embodiments mentioned in the present invention describe some methods or systems based on a series of steps or devices. However, the present invention is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiments, or in a different order from the embodiments, or several steps can be performed simultaneously.

[0155] In the present invention, features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, and / or combined with features of other embodiments or replace features of other embodiments.

[0156] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. An abnormal log alarm method, characterized in that: The method comprises the following steps: Log common pattern set generation step: for multiple normal logs in the log library, determine the log mode to which each normal log belongs, and generate a log common pattern set based on the normal logs of each log mode; the log common pattern set generation step includes: Extracting normal logs from the log library, determining whether the established log pattern set contains a log pattern that matches the extracted log, and adding the extracted log to the log pattern set if it is determined that the log pattern set does not contain a log pattern that matches the extracted log; Clustering the extracted normal logs based on the log pattern to obtain a log set of one or more log patterns clustered according to the log pattern; and Generate a log common pattern corresponding to each log pattern based on the common pattern of each log in the log set of each log pattern, and generate a log common pattern set based on the common pattern corresponding to each log pattern; Receive new logs; Determine whether the received new log matches a log common pattern in the log common pattern set, and determine whether the received new log is an abnormal log based on the matching result; When it is determined that the received new log is an abnormal log, an alarm message is generated.

2. The method according to claim 1, characterized in that The determining whether the established log pattern set contains the log pattern matched by the extracted log, and if it is determined that the log pattern set does not contain the log pattern matched by the extracted log, adding the extracted log to the log pattern set, includes: Determine whether the log pattern set is empty, and if it is determined that the log pattern set is empty, add the extracted log to the log pattern set; When it is determined that the log pattern set is not empty, whether the log pattern set contains a log pattern that matches the extracted log is determined by comparing the distance between the extracted log and the log in the log pattern set with a predetermined distance threshold; and when it is determined that the log pattern set does not contain a log pattern that matches the extracted log, the extracted log is added to the log pattern set.

3. The method according to claim 2, characterized in that The step of determining whether the log pattern set contains a log pattern matched by the extracted log according to the comparison between the distance between the extracted log and the log in the log pattern set and a predetermined distance threshold comprises: Selecting logs one by one from the log pattern set in a predetermined order, and determining the length of the extracted log and the currently selected log based on the number of words; Determine the number of words that are the same in the extracted log and the currently selected log; Calculate the distance between the two logs based on the ratio of the number of words in common between the extracted log and the currently selected log and the length of the larger of the two logs; Based on the comparison between the calculated distance and a predetermined distance threshold, it is determined whether the log pattern set contains the log pattern matched by the extracted log.

4. The method according to claim 3, characterized in that The distance between the two logs is calculated based on the following formula: score(logi,logj)=1-match(logi,logj) / max(len(logi),len(logj)); Among them, logi and logj represent two logs respectively, score(logi,logj) represents the distance between the two logs, match(logi,logj) represents the number of identical words in the two logs, and max(len(logi),len(logj)) represents the larger length of the two logs.

5. The method according to claim 1, characterized in that Generate a log common pattern corresponding to each log pattern based on the common pattern of each log in the log set of each log pattern, and generate a log common pattern set based on the common pattern corresponding to each log pattern, including: For the log set of each log pattern, when the number of logs in the log set is one, the log itself is used as the log common pattern corresponding to the current log set; when there are more than two logs in the log set of the current log pattern, the log common pattern corresponding to each log pattern is generated in the following way: the two adjacent logs in each log pattern are compared in sequence, the common pattern obtained after comparison is used as the current log common pattern, and the current log common pattern is compared with the next log in sequence, the common pattern obtained is used to update the current log common pattern, and the current log common pattern obtained after traversing all logs is used as the log common pattern corresponding to the current log pattern.

6. The method according to claim 1, characterized in that The determining whether the received new log matches the log common pattern in the log common pattern set, and determining whether the received new log is an abnormal log based on the matching result, includes: The new log is compared with the log common pattern in the log common pattern set; if it is determined that the new log belongs to any log common pattern in the log common pattern set, it is determined that the received new log matches the log common pattern in the log common pattern set, thereby determining that the received new log is not an abnormal log; if it is determined that the new log does not belong to any log common pattern in the log common pattern set, it is determined that the received new log does not match the log common pattern in the log common pattern set, thereby determining that the received new log is an abnormal log.

7. The method according to claim 1 or 2, characterized in that: The method further comprises: If it is determined that the log pattern set contains a log pattern matching the extracted log, the extracted log is not added to the log pattern set.

8. An abnormal log alarm device, comprising a processor and a memory, characterized in that: The memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the device implements the steps of the method as described in any one of claims 1 to 7.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.