System log anomaly detection system and method based on comparative learning and attention mechanism

By using the anomaly detection method of contrastive learning and attention mechanism in the information system, the problem of automatic identification of log anomalies in complex systems is solved, the efficiency and reliability of log analysis are improved, and efficient processing and anomaly detection of massive log data are achieved. .

CN118585367APending Publication Date: 2024-09-03CHONGQING UNIV
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410729448.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-06
Publication Date
2024-09-03

AI Technical Summary

Technical Problem

It is difficult for existing technologies to effectively automatically identify and process the ever-changing abnormal logs in complex information systems. Traditional methods rely on predefined patterns and high-quality annotated data, and are difficult to cope with the analysis and processing of massive log data.

Method used

The system log anomaly detection method based on contrastive learning and attention mechanism is adopted. Through contrastive learning encoder and neural network model, combined with the approximate nearest neighbor algorithm and attention mechanism, the feature vector of the log is extracted, anomaly detection is performed, and it is completed through the softmax function. Classification tasks provide knowledge graphs to assist judgment.

Benefits of technology

It improves the efficiency and reliability of massive information system log analysis, breaks through unstructured log data preprocessing and log data visual analysis, and achieves more efficient anomaly detection and maintenance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118585367A
    Figure CN118585367A
Patent Text Reader

Abstract

The invention relates to a system log anomaly detection system and method based on comparative learning and an attention mechanism, and belongs to the field of information system operation and maintenance. According to the method, effective detection of the abnormal behaviors of the system is realized by utilizing a comparative learning and attention mechanism and combining the characteristics of system log data. The method mainly comprises the following steps of collecting system log data, performing preprocessing including cleaning and feature extraction on the system log data, obtaining feature vectors of the log data by utilizing the data and based on comparative learning and an attention mechanism, training a neural network model according to the feature vectors and labels, and obtaining the log data. A system capable of detecting whether the log is abnormal or not according to the log information is obtained, so that the detection precision and efficiency of the abnormal behavior of the information system are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of information system operation and maintenance, and relates to a system log anomaly detection system and method based on contrastive learning and attention mechanism. Background Art

[0002] In modern information technology systems, system logs are an important tool for recording system operation status, events, and errors. System logs include not only logs of hardware devices and operating systems, but also logs generated by applications, network devices, etc. These logs record various behaviors of the system during operation, which can help administrators monitor system health, locate the root cause of problems, perform performance analysis, and conduct audits.

[0003] As information systems become increasingly complex, the size of log data has increased dramatically, and manual analysis of these logs has become increasingly unrealistic. Traditional log analysis methods mainly rely on keyword search and rule-based matching, but these methods usually require pre-definition of abnormal patterns and are difficult to cope with the ever-changing system environment and diverse abnormal situations. Therefore, it is particularly important to develop an effective system log anomaly detection method that can automatically identify potential anomalies and problems.

[0004] In recent years, anomaly detection methods based on machine learning and data mining have received extensive attention and application in the field of system log analysis. These methods automatically identify abnormal behaviors by analyzing patterns and features in log data. Among them, supervised learning methods transform the anomaly detection problem into a classification problem, training classifiers with labeled normal and abnormal log data to automatically identify new abnormal logs. However, the effectiveness of such methods depends on high-quality labeled data sets. The development of system log anomaly detection methods aims to improve the accuracy, timeliness and automation of detection, helping system administrators to more effectively maintain the normal operation of the system and prevent and deal with potential problems. Summary of the invention

[0005] In view of this, the object of the present invention is to provide a system log anomaly detection system and method based on contrastive learning and attention mechanism.

[0006] In order to achieve the above object, the present invention provides the following technical solutions:

[0007] A system log anomaly detection system based on contrastive learning and attention mechanism comprises a log collection module, a log parsing module, an anomaly detection module and a front-end and back-end module; the log collection module is used for collecting logs generated by the system from various systems in real time in a distributed manner, including log-related information; the log parsing module extracts the log generation time, the system to which the log belongs, and the key information of the log according to the collected original log semi-structured information to form structured log data; the anomaly detection module processes the log data through a trained contrastive learning encoder and a neural network model, and then transmits the log data to the model to determine whether it is abnormal; the front-end and back-end modules are used to help system administrators maintain the normal operation of the system more effectively, prevent and deal with potential problems, wherein each structured log information and whether it is abnormal are displayed, and a knowledge graph is provided for further determining messages associated with abnormal logs.

[0008] A system log anomaly detection method based on contrastive learning and attention mechanism is proposed. In the anomaly detection module, a training strategy of supervised contrastive learning loss function is designed to obtain high-quality text vector representation, build a data repository of training set, and obtain contrastive learning encoder; secondly, the approximate nearest neighbor algorithm is used to obtain high-quality adjacent training instances; then, an attention mechanism is constructed to perform attention distribution learning on adjacent training instances to obtain more and more comprehensive similar features; then, the constructed attention mechanism is spliced ​​into the fully connected layer of the model; finally, the classification task is completed through the softmax function, and the log anomaly detection result is finally obtained.

[0009] The contrastive learning encoder adopts weighted joint optimization training of contrastive loss function and cross entropy function. According to the characteristics of system logs, the cross entropy function takes cosine similarity as the optimization direction and introduces imbalance adjustment for the fact that abnormal log data is far less than normal data. Ultimately, the trained contrastive learning encoder can better distinguish normal and abnormal logs, and perform text vectorization on the log information, so that the cosine similarity between the data with the same label is closer and the cosine similarity between the data with different labels is farther.

[0010] The log text vector obtained by the contrastive learning encoder is used to obtain the attention-weighted text vector and attention-weighted label vector of the log through the attention mechanism. The log text vector, attention-weighted text vector and attention-weighted label vector obtained by contrastive learning encoding of the log information are combined to obtain the feature vector of the log, which can be combined with its training label as the training input of the neural network model.

[0011] After the neural network model is trained, when performing log anomaly detection, each collected log information will be subjected to contrast learning and attention mechanism again to obtain a feature vector. When the feature vector is input into the neural network model, the log anomaly detection result is obtained.

[0012] Furthermore, the modification of the loss function of the original contrastive learning BERT model is determined by the key information part of the semi-structured log, making it more suitable for the semi-structured system log data.

[0013] Furthermore, the optimal training log feature vector set obtained based on contrastive learning and attention mechanism is determined by the original optimal log vector set after contrastive learning, the attention weighted text vector set, and the attention weighted label vector set.

[0014] The beneficial effects of the present invention are: based on contrastive learning and attention mechanism, the collection and analysis technology of massive logs in a distributed environment is studied, key technologies such as unstructured log data preprocessing, log data visualization analysis and information system anomaly detection method based on log data sequence analysis are broken through, and the efficiency and reliability of massive information system log analysis are improved.

[0015] Other advantages, objectives and features of the present invention will be described in the following description to some extent, and to some extent, will be obvious to those skilled in the art based on the following examination and study, or can be taught from the practice of the present invention. The objectives and other advantages of the present invention can be realized and obtained through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention will be described in detail below in conjunction with the accompanying drawings, wherein:

[0017] Figure 1 This is the structure diagram of the system log anomaly detection system based on contrastive learning and attention mechanism;

[0018] Figure 2 The flowchart of the system log anomaly detection method based on contrastive learning and attention mechanism. DETAILED DESCRIPTION

[0019] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the illustrations provided in the following embodiments only illustrate the basic concept of the present invention in a schematic manner, and the following embodiments and features in the embodiments can be combined with each other without conflict.

[0020] Among them, the drawings are only used for illustrative explanations, and they only represent schematic diagrams rather than actual pictures, and should not be understood as limitations on the present invention. In order to better illustrate the embodiments of the present invention, some parts of the drawings may be omitted, enlarged or reduced, and do not represent the size of actual products. For those skilled in the art, it is understandable that some well-known structures and their descriptions in the drawings may be omitted.

[0021] The same or similar numbers in the drawings of the embodiments of the present invention correspond to the same or similar parts; in the description of the present invention, it should be understood that if the terms "upper", "lower", "left", "right", "front", "rear", etc. indicate the orientation or position relationship, they are based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation. Therefore, the terms describing the position relationship in the drawings are only used for illustrative purposes and cannot be understood as limiting the present invention. For ordinary technicians in this field, the specific meanings of the above terms can be understood according to specific circumstances.

[0022] Figure 1 The present invention is a structural diagram of a system log anomaly detection system based on contrastive learning and attention mechanism; the system includes a log collection module, a log parsing module, an anomaly detection module and a front-end and back-end module; the log collection module is used to collect the logs generated by the system from each system in real time in a distributed manner, including log-related information; the log parsing module extracts the log generation time, the system to which the log belongs, and the key information of the log according to the collected semi-structured information of the original log to form structured log data; the anomaly detection module processes the log data through the trained contrastive learning encoder and neural network model, and then passes it into the model to determine whether it is abnormal; the front-end and back-end modules are used to help system administrators maintain the normal operation of the system more effectively, prevent and deal with potential problems, wherein each structured log information and whether it is abnormal are displayed, and a knowledge graph is provided for further determining the messages associated with the abnormal log.

[0023] Figure 2 This is a flow chart of the system log anomaly detection method based on contrastive learning and attention mechanism. In the anomaly detection module, first in the training phase, since the key information part of the system log is semi-structured text, all the key information parts in the training log data set are extracted into log template data through the drain3 algorithm, and then the log template data set is preprocessed, the jieba word library is used for text segmentation, the BERT model is used for stop word removal and text vectorization, and training is performed according to the modified loss function to obtain the contrastive learning encoder and the text vector set of the log template data set.

[0024] In order to make the model focus on the information between the logs with the same label that are more related, and reduce the attention to the information between the logs with different labels, the attention mechanism is performed according to the log training template text vector set. First, the approximate nearest neighbor algorithm is used to obtain the neighboring logs of each training text vector. Through cosine similarity, for each training template log, according to its comparative learning text vector, the k logs with the closest cosine similarity except itself are retrieved from the comparative learning training log text vector set. These k log template data are the neighboring logs of the training template log. For the training log set, each training log has k neighboring logs.

[0025] The attention mechanism is constructed using the trained Word2vec encoder. The Google trained Word2vec model "word2vec-google-news-300" is introduced. This model is trained on the Google News dataset. The dataset covers a large number of news articles from the Google News website, including rich text content. The dimension of each word vector obtained by the model is 300 dimensions, which means that each word is represented as a vector containing 300 real values, which capture the semantic information of the word in the semantic space. First, the text preprocessing is performed on each training log and its k adjacent logs. Then, the words in each log are word vectorized through the model. All the word vectors in a log are evenly divided to obtain the text vector of the log. Finally, the Word2vec log template text vector set is obtained, where each log template has (k+1) text vectors and their respective labels, and each text vector is 300 dimensions.

[0026] For each Word2vec-encoded log text vector and its k adjacent log text vectors, the attention scoring function is used to calculate the attention distribution of each Word2vec-encoded log text vector, where h i represents the i-th adjacent log text vector; y i represents the label of the ith adjacent log, a normal log represents 0, and an abnormal log represents 1; c(hi,hj) represents the cosine similarity between the ith log text vector and the jth text vector. According to the w in the attention distribution W i The corresponding adjacent log text vectors are weighted averaged to obtain the attention weighted text vector, and the attention distribution W is calculated according to w i The labels of the corresponding adjacent logs are weighted averaged to obtain the attention weighted label.

[0027] Finally, an optimal training log feature vector set is obtained through contrastive learning and attention mechanism, where each training log feature vector contains the text vector encoded by the contrastive learning encoder, the attention weighted text vector and the attention weighted label. The log training feature vector set and the label are input into the pre-trained BERT encoder for neural network model training to obtain a trained model. When performing log anomaly detection, after a piece of collected test log data is input into the system, the text is first pre-processed, and the log data after text pre-processing is input into the contrastive learning encoder to obtain the text vector of the test log. The test log data and the text vector are input into the attention mechanism, and the k log templates with the closest cosine similarity in the training log template are searched according to the text vector. After the trained word2vec encoding and attention weighting, the attention weighted text vector and attention weighted label vector of the test log are obtained. The three vectors are spliced ​​to obtain a (300+301k)-dimensional vector, which is input into the trained model to obtain the prediction result, which is 0 for normal and 1 for abnormal, completing the log anomaly detection.

[0028] The system log information generated by each system is collected through the log collection module, and the structured log data is obtained through the log parsing module. On this basis, comparative learning and attention mechanisms are used, relying on relevant software and hardware devices with programming functions to obtain log anomaly judgment results, and then the structured log information and judgment results are displayed on the front-end page.

[0029] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solution, which should be included in the scope of the claims of the present invention.

Claims

1. A system log anomaly detection system based on contrastive learning and attention mechanism, characterized by: The system includes a log collection module, a log parsing module, an anomaly detection module and front-end and back-end modules; The log collection module is used to collect the logs generated by the system from each system in real time in a distributed manner, including log-related information; The log parsing module extracts the log generation time, the system to which the log belongs, and the key information of the log according to the collected original log semi-structured information to form structured log data; The anomaly detection module processes the log data through the trained contrast learning encoder and neural network model and then passes it into the model to determine whether it is abnormal; The front-end and back-end modules are used to help system administrators maintain the normal operation of the system more effectively, prevent and deal with potential problems. Each structured log information is displayed and whether it is abnormal. A knowledge graph is also provided to further determine the messages associated with abnormal logs.

2. A system log anomaly detection method based on contrastive learning and attention mechanism based on the system of claim 1, characterized in that: The method comprises the following steps: S1: Determine the loss function of the contrastive learning BERT model in system log anomaly detection: Define the loss function L of the BERT model sup =L ce +L con , where L ce is the original loss function, that is, the cross entropy loss function, L con is the supervised contrast loss function: Where N is the total number of training logs, N0 and N1 represent the number of normal logs and abnormal logs respectively; h i is the text vector of the i-th log data; c(h i ,h j ) represents the cosine similarity between the i-th log text vector and the j-th text vector; g(y i ,y k ) is an additional function, introducing penalties or rewards based on log i and j labels, and adjusting the imbalance based on the fact that log abnormal data is far less than normal data y i Indicates the label of the i-th log, "INFO" is assigned a value of 0 for a normal log, and "WARN" is assigned a value of 1 for an abnormal log; the contrast loss function is added to the cross entropy loss function and used as the loss function for BERT model training; S2: Determine the normal system log training text vector representation and construct the optimal training log feature vector M = {B, W, Y}; Among them, B is the original optimal log vector set after comparative learning: the log template set is extracted through drain3, and the BERT model built based on S1 is trained to make the cosine similarity between the same label data closer and the cosine similarity between different label data farther, so as to obtain the original optimal log vector set; W is the attention-weighted text vector obtained by the attention mechanism: through the original optimal log vector set B, the approximate nearest neighbor algorithm is performed on each optimal log vector to obtain k adjacent text vectors, and the trained Word2vec encoder is used to obtain (k+1) text vectors and their respective labels, and the attention distribution is obtained to obtain the attention-weighted text vector; Y is the attention weighted label vector: the labels of the corresponding adjacent logs are weighted averaged according to the attention distribution to obtain the attention weighted label; S3: Using contrastive learning and attention mechanism, relying on relevant software with programming functions, and according to the content of S1 and S2 and system log data, a system log anomaly detection system based on contrastive learning and attention mechanism is implemented.

3. The system log anomaly detection method based on contrastive learning and attention mechanism according to claim 2 is characterized in that: The loss function of the original contrastive learning BERT model is modified, and a supervised contrastive learning loss function training strategy is designed. Weighted joint optimization training is performed through contrastive loss function and cross entropy function. The cross entropy function uses cosine similarity as the optimization direction, and introduces imbalance adjustment for the log abnormal data that is far less than normal data to enhance the training effect.

4. The system log anomaly detection method based on contrastive learning and attention mechanism according to claim 2 is characterized in that: The optimal training log feature vector set obtained based on contrastive learning and attention mechanism is determined by the original optimal log vector set after contrastive learning, the attention weighted text vector set, and the attention weighted label vector set; for each log data, when used as the input vector of the neural network model, the feature vector is obtained by contrastive learning encoder and attention mechanism for each collected log, rather than log template.

5. The system log anomaly detection method based on contrastive learning and attention mechanism according to claim 4 is characterized in that: The contrastive learning encoder is obtained by training the BERT encoder after modifying the loss function based on the system log and the log template data; the contrastive learning encoder clusters the normal or abnormal log vectors into two groups on the cosine similarity, encodes the log data to obtain the text vector, and the cosine similarity difference between the normal and abnormal logs is larger, while the difference between the same labels is smaller.

Citation Information

Cited By

  • Vector database system based on query distribution perception

    CN120067147A

  • Log abnormal behavior analysis method and system based on sorting learning and attention mechanism

    CN120407337A

  • Log abnormal behavior analysis method and system based on ranking learning and attention mechanism

    CN120407337B