A log parameter anomaly detection method based on word embedding
By converting log parameters into continuous word vectors and using a long short-term memory neural network model, the problem of dynamic log parameter detection is solved, unified detection of different types of parameters is achieved, and the accuracy and efficiency of detection are improved.
Patent Information
- Application Number
- CN202010880971.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-27
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2040-08-27
AI Technical Summary
Existing technology is difficult to effectively detect anomalies in dynamic log parameters, especially the difficulty in detection due to the dynamics and differences of parameters. Moreover, existing methods only target continuous type parameters, have redundant models and lack practical deployment capabilities.
Using a method based on word embedding, the discrete parameters in the log are converted into continuous parameter word vectors, the long short-term memory neural network model is used to train the word vector, and cosine similarity is used for parameter anomaly detection to achieve different log templates and types of parameters. unified detection.
It achieves efficient and accurate detection of dynamic log parameters, can detect unknown types of parameter anomalies without increasing model complexity, and improves the overall accuracy of log detection.
Smart Images

Figure CN112069787B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of Internet technology and relates to a log parameter anomaly detection method based on word embedding. Background Art
[0002] Logs are an important part of all kinds of computer systems. System logs can reflect the execution process and status of computer programs, and can also identify errors and anomalies generated by systems and programs during execution. Due to the importance of logs, log anomaly detection has always been a hot research topic. Most of the current anomaly detection methods classify logs into log templates with fixed formats, and complete log anomaly detection through the time series information of log templates through data statistics, machine learning, deep learning and other methods. However, in various types of computer logs, in addition to log templates with fixed formats and categories, there are also a large number of dynamic log parameters. Log templates can be used to identify anomalies in the execution sequence of programs, but some anomalies cannot be detected only through the time series of log templates. Parameters are dynamic, which is specifically reflected in the dynamics of text content and quantity, that is, the value of the parameter itself will change with the advancement of time series, and the parameter format and quantity of different log templates are also different. Parameters that are similar to variables not only introduce uncertainty in logs, but also increase the difficulty of log detection.
[0003] For the more difficult parameter anomaly detection, some methods are based on log templates, dividing the parameters into different parameter vectors according to the log templates, and training a deep learning model for each log template to complete the time parameter anomaly detection. This method only targets continuous parameter variables, and the model is redundant and does not have practical deployment capabilities. Summary of the invention
[0004] The purpose of the present invention is to overcome the shortcomings of the above-mentioned prior art and provide a log parameter anomaly detection method based on word embedding, which can effectively solve the detection bottleneck caused by the dynamic and diverse nature of parameters and improve the overall accuracy of log detection.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions:
[0006] A log parameter anomaly detection method based on word embedding, characterized by comprising the following steps;
[0007] Step 1: parse all the parameters in the log and separate the discrete parameters from all the parameters;
[0008] Step 2: Convert discrete parameters into continuous parameter word vectors;
[0009] Step 3: Use the long short-term memory neural network model to train the parameter word vector, and use the trained parameter word vector to predict the parameter word vector at the subsequent target moment;
[0010] Step 4: Use cosine similarity to determine the degree of association between the predicted parameter word vector and the target parameter word vector, calculate the loss value based on the degree of association, and then feed the loss value back to the network to update and optimize the model until convergence;
[0011] Step 5: Obtain logs for parameter anomaly detection and calculate the cosine similarity between the predicted parameters and the target parameters. If the cosine similarity is lower than the threshold, log parameter anomaly is detected.
[0012] Preferably, in step 1, all log templates in the log are parsed by the Spell method, all parameters in the log are filtered out according to the log template, and discrete parameters are separately divided out by regularization judgment.
[0013] Preferably, in step 2, a word vector dictionary is constructed with all discrete parameters, and word embedding training is performed on the word vector dictionary. After training with a self-supervised word2vec model, all valid words in the word vector dictionary are converted into parameter word vectors with fixed dimensional values that are interrelated with each other, that is, continuous parameter word vectors.
[0014] Preferably, in step three, the parameter word vectors are screened out from the word vector dictionary, and data processing is performed in the original time sequence in a way that compromises parameter position and log timing. Each input is all the parameter word vectors in the complete log within a certain window before the log at the target moment, and a long short-term memory neural network model is used to calculate and predict the parameter word vectors at subsequent target moments.
[0015] Furthermore, the long short-term memory neural network model includes an input layer, multiple hidden layers and an output layer connected in sequence.
[0016] Preferably, in step 4, cosine similarity is used to measure the angle between the prediction parameter word vector and the target parameter word vector. The similarity between vectors can be quantified from the direction by calculating the cosine value of the angle between the two vectors. If the two vectors are in the same direction, the cosine value is 1, and if the two vectors are in opposite directions, the cosine value is -1. The formula is:
[0017] Preferably, in step five, the log is input into the long short-term memory neural network model according to a certain set window, the predicted parameter word vector is output, and the target parameter word vector and the predicted parameter word vector are compared using cosine similarity. When the cosine similarity is less than a threshold, it is judged as abnormal, and when the cosine similarity is greater than or equal to the threshold, it is judged as normal.
[0018] Compared with the prior art, the present invention has the following beneficial effects:
[0019] The detection method of the present invention uses a universal model to complete the detection of parameter anomalies, without the need to specially design and train multiple models for various specific anomalies, and can implement a unified detection model for different log templates. The present invention implements structured modeling and analysis of different types of parameters, and implements a log parameter detection model with complete logs as the detection target. After log parsing, the natural log sequence is used to complete the detection without providing human intervention. It can have efficient and accurate detection capabilities for parameter anomalies of unknown types. In the case where the data set does not include specific categories of anomalies, the method proposed by the present invention can effectively and accurately detect anomalies in parameters. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a detection flow chart of the present invention;
[0021] Figure 2 Schematic diagram of the parameter anomaly detection training method of the present invention. DETAILED DESCRIPTION
[0022] The present invention is further described in detail below in conjunction with the accompanying drawings:
[0023] like Figure 1 FIG. 1 is a flow chart of a method for detecting anomalies in log parameters based on word embedding according to the present invention. The detection method according to the present invention comprises the following steps:
[0024] Step 1: Regularization analysis of parameters:
[0025] Logs are plain text, part of which is fixed and the other part is variable. For example, given the logs "Newswitch connected from 127.0.0.1:54000" and "New switch connected from127.0.0.1:54112", the four words "New", "switch", "connected" and "from" are considered as constant parts, because they are always unchanged, called log templates. The rest are called variable parts, because they present different states in different situations. The variable part can be abstracted as an asterisk in the constant part, that is, "New switch connected from*". Each variable part can be called a parameter. At the same time, for each log, a set of parameters can form a vector, called a parameter vector. Use the Spell method to perform structured parsing of the log to obtain a set of log templates, each template matches a set of parameter vectors. In the specific implementation process, in addition to the basic Spell method parsing operation, two operations are required: 1) When using the log template to filter parameters, introduce multiple regular judgment items to filter out words such as time, date, and long letter strings in the log. These words must be log parameters. Filtering them in advance and marking them with asterisks can increase the accuracy of the Spell method in parsing logs. After log parsing, the parameters are divided into two categories: discrete parameters and continuous parameters through regularization judgment. Continuous parameters refer to continuous numerical parameters such as time and date. 2) During the whole process, as each log parameter is filtered, the maximum number of parameters max_param is continuously updated, that is, the maximum number of parameters in a log.
[0026] Step 2: Construct a word vector dictionary with all discrete parameters, train the word embedding model, and convert the discrete parameters in text format into continuous numerical form:
[0027] The main purpose of word embedding training is to convert the parameters parsed in the first stage into low-dimensional word vector form so that the model can detect both continuous and discrete parameters. In the selection of word vector dictionary, although subsequent training and detection only require the word vector of the parameter, the essence of detecting parameter anomalies through word vector is to complete the prediction through the feature association between parameters, and the word embedding training model used in this article uses adjacent words to predict and constrain the current word, thereby completing the model update and data training. In the log, a considerable part of the words adjacent to the parameter variables belong to the log template, so the training data at this stage is all the text in the log, and these texts are combined into a dictionary for word embedding training.
[0028] The input of the word embedding training phase is the word vector dictionary of log text in normal log order, and the output is the parameter word vector of all valid words in the word vector dictionary, that is, continuous parameter word vector. Its implementation process is as follows:
[0029] 1) Input log file;
[0030] 2) Count the number and frequency of words in the log, separated by spaces;
[0031] 3) Filter out words whose frequency is below a certain threshold;
[0032] 4) Combining the remaining words into input and output;
[0033] 5) Network training.
[0034] The threshold in 3) is to filter out words that appear too rarely in the dictionary. This article mainly filters out words in the following situations: 1) Continuous parameter variables. Generally speaking, the number of times a continuous parameter variable appears is 1. As mentioned above, continuous parameters do not participate in word embedding training. Continuous parameter variables have been preliminarily screened in the previous stage, and will be screened again in this stage to ensure accuracy. 2) Parameters with extremely low frequency in the dictionary. The frequency of these parameters is not enough to support the word embedding network training to analyze its feature vector, and in large-scale natural language dictionaries, low-frequency words have a low impact weight in anomaly detection tasks.
[0035] Step 3: Use the Long Short Term Memory (LSTM) neural network model to train the parameter word vector and predict the distribution of the parameters at the next moment:
[0036] The parameter word vectors are selected from the word vector dictionary, and the data is processed in the original time sequence in a way that compromises the parameter position and log time sequence. Each input is all the parameter word vectors in the complete log within a certain window before the log at the target moment. The long short-term memory neural network model is used to calculate and predict the parameter word vectors at the subsequent target moment.
[0037] There are long-term dependencies between computer system logs, so the present invention uses a long short-term memory neural network (LSTM) model to train historical messages, including an input layer, multiple hidden layers and an output layer connected in sequence. In the previous step, the present invention converts the text type parameter variables into numerical type parameter word vectors, such as Figure 2 As shown, in this step, the present invention uses an input method that considers both the parameter position relationship and the log time sequence relationship. First, all log parameters are filled with all-zero vectors according to the maximum number of parameters, that is, logs that are less than the maximum number of parameters max_param are filled with all-zero vectors to max_param. Figure 2 The maximum number of parameters in is 4. Then the word vectors of all words in each parameter position are added to form the parameter word vector of the current parameter position. Finally, a sliding window with a size of an integer multiple of max_param is used to ensure that each input must contain a complete log. The step size of each window sliding is max_param. The long short-term memory neural network model is input trained, and the network's prediction of the parameter word vector distribution at the target time is obtained after forward propagation.
[0038] Step 4: Use cosine similarity to determine the degree of association between the predicted parameter word vector and the target parameter word vector, calculate the loss value based on the degree of association, and then feed the loss value back to the network to update and optimize the model until convergence:
[0039] For two vectors, cosine similarity is used to measure the size of their angle. The similarity between vectors can be quantified from the direction by calculating the cosine value of the angle between the two vectors. If the two vectors are in the same direction, the cosine value is 1, and if the two vectors are in opposite directions, the cosine value is -1. The formula is: The output of the model of the present invention is the word vector that predicts all the parameters of the log at the current moment. The ideal output result of the model should be a set of word vectors with a cosine similarity of 1 with the target parameter vector, indicating that the predicted value is completely consistent with the target value. Therefore, in actual training, after calculating the cosine similarity, the L1 loss function is used to calculate its loss value with 1, and the network model is fed back and updated.
[0040] Step 5: Obtain logs online for parameter anomaly detection and calculate the cosine similarity between the predicted parameter word vector and the target parameter word vector. If the cosine similarity is lower than a certain threshold, an anomaly is detected:
[0041] After the model training is completed, the actual detection log is parsed according to the parsing and classification results of the training log in the log parsing phase. In this process, the current log template or template category will not be added or modified. Then the model is used to detect the log, and the log is input into the neural network model according to a certain set window, and the prediction parameters are output. The target parameters and the prediction parameters are compared using cosine similarity, and the cosine similarity threshold is set, such as 0.5. If it is less than this threshold, it is judged as abnormal.
[0042] The method proposed in the present invention can effectively and accurately detect anomalies in parameters. As shown in Table 1, the upper and lower columns are the detection results of two completely different computer system log data sets, where the detection F value of the OpenStack data set can reach 94.74%, and the detection recall rate of the SDN data set is 94%, which shows the effectiveness and accuracy of the method in anomaly detection.
[0043] Table 1 Parameter anomaly detection model results
[0044]
[0045] The above contents are only for explaining the technical idea of the present invention and cannot be used to limit the protection scope of the present invention. Any changes made on the basis of the technical solution in accordance with the technical idea proposed by the present invention shall fall within the protection scope of the claims of the present invention.
Claims
1. A log parameter anomaly detection method based on word embedding, characterized in that: The method comprises the following steps: Step 1: parse all the parameters in the log and separate the discrete parameters from all the parameters; Step 2: Convert discrete parameters into continuous parameter word vectors; Step 3: Use the long short-term memory neural network model to train the parameter word vector, and use the trained parameter word vector to predict the parameter word vector at the subsequent target moment; In step 3, the parameter word vectors are selected from the word vector dictionary, and data processing is performed in the original time sequence in a way that compromises the parameter position and log time sequence. Each input is all the parameter word vectors in the complete log within a certain window before the log at the target time. The long short-term memory neural network model is used to calculate and predict the parameter word vectors at the subsequent target time. The LSTM neural network model includes an input layer, multiple hidden layers, and an output layer connected in sequence; Step 4: Use cosine similarity to determine the degree of association between the predicted parameter word vector and the target parameter word vector, calculate the loss value based on the degree of association, and then feed the loss value back to the network to update and optimize the model until convergence; In step 4, cosine similarity is used to measure the angle between the prediction parameter word vector and the target parameter word vector. The similarity between vectors can be quantified from the direction by calculating the cosine value of the angle between the two vectors. If the two vectors are in the same direction, the cosine value is 1, and if the two vectors are in opposite directions, the cosine value is -1. The formula is: ; Step 5: Obtain logs for parameter anomaly detection, calculate the cosine similarity between the predicted parameters and the target parameters, and if the cosine similarity is lower than the threshold, log parameter anomaly is detected; In step five, the log is input into the long short-term memory neural network model according to a certain set window, the predicted parameter word vector is output, and the target parameter word vector and the predicted parameter word vector are compared using cosine similarity. When the cosine similarity is less than the threshold, it is judged as abnormal, and when the cosine similarity is greater than or equal to the threshold, it is judged as normal.
2. The method for detecting anomalies in log parameters based on word embedding according to claim 1, characterized in that: In step 1, all log templates in the log are parsed using the Spell method, all parameters in the log are filtered out according to the log template, and discrete parameters are separated out separately through regularization judgment.
3. The method for detecting anomalies in log parameters based on word embedding according to claim 1, characterized in that: In step 2, a word vector dictionary is constructed with all discrete parameters, and word embedding training is performed on the word vector dictionary. After training with the self-supervised word2vec model, all valid words in the word vector dictionary are converted into parameter word vectors with fixed dimensional values that are interrelated with each other, that is, continuous parameter word vectors.
Citation Information
Patent Citations
Virtual machine process exception behavior detection method and system
CN108121593A
Message anomaly detection method adopting deep learning in SDN
CN110535723A
Network anomaly early warning method based on log analysis
CN110691070A
Intranet lateral movement detection system and method based on graph representation learning
CN111049680A
Power grid dispatching log word vector extraction method based on improved skip-gram model
CN111160022A
